Notifications
Clear all

Calendário

8 Posts
2 Usuários
0 Reactions
1,068 Visualizações
(@vonzuben)
Posts: 549
Prominent Member
Topic starter
 

Ao preencher a celula com a data, não quero que abre o calendário ao clicar na celula novamente, somente se tiver vazio.

Tentei usar um If, se caso vazio, abre

As vezes trocar o mês Ex: 03 para 04, não vejo necessidade de abrir o calendário, apenas troca o número na celula

https://www.sendspace.com/file/qnpei1

Obrigado !

 
Postado : 22/04/2018 6:34 pm
(@klarc28)
Posts: 0
New Member
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Value = "" Then
    Dim Cancel As Boolean
    Dim Linha As String
    Dim DateFormats, DF
    
    Linha = Target.Row
        
    DateFormats = Array("m/d/yyyy", "dd mmmm yyyy")
    
    'If Range("N" & Linha) = "" Then
    
    For Each DF In DateFormats
    
        If DF = Target.NumberFormat Then
            If CalendarFrm.HelpLabel.Caption <> "" Then
                CalendarFrm.Height = 191 + CalendarFrm.HelpLabel.Height
            Else: CalendarFrm.Height = 191
                CalendarFrm.Show
                Cancel = True
            End If
        End If
    
    Next
    
    'End If
    End If
    
End Sub
 
Postado : 22/04/2018 6:43 pm
(@vonzuben)
Posts: 549
Prominent Member
Topic starter
 

klarc28

Era só trocar isso

If Range("N" & Linha) = "" Then

por isso

If Target.Value = "" Then
 
Postado : 22/04/2018 7:44 pm
(@vonzuben)
Posts: 549
Prominent Member
Topic starter
 

Acho que vou usar BeforerightClick, caso o usuário abrir o calendário e fechar, ele terá que clicar em outra celula e voltar clicar na celula novamente para funcionar.
Só seu tirar o botão X, obrigando a preencher.

 
Postado : 22/04/2018 8:11 pm
(@vonzuben)
Posts: 549
Prominent Member
Topic starter
 

Como faço para quando fechar o calendário jogar a seleção da celula para direita ?

Coloquei esse código. mas não funcionou !

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

    If CloseMode = 0 Then
        ActiveCell.Offset(0, 1).Select
    End If
End Sub
 
Postado : 22/04/2018 9:24 pm
(@klarc28)
Posts: 0
New Member
 
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
ActiveCell.Offset(0, 1).Select
End Sub
 
Postado : 22/04/2018 9:59 pm
(@vonzuben)
Posts: 549
Prominent Member
Topic starter
 

klarc28

Não funcionou, seleção continua na mesma celula

 
Postado : 23/04/2018 6:58 pm
(@vonzuben)
Posts: 549
Prominent Member
Topic starter
 

Deu certo ! Até meu código estava certo !
Tinha colocado na Plan e o correto é dentro do código do form

Valeu !

 
Postado : 23/04/2018 7:59 pm