sou entusiasta em excel e estou montando uma planilha de ponto de funcionários
adqui umcodigo vba no chatgpt mas não entendi como inserir no excel...
o código é esse:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim linha As Long
If Target.Column <> 7 Then Exit Sub 'Coluna de Observações
If LCase(Target.Value) <> "marca" Then Exit Sub
linha = Target.Row
If Cells(linha, 2).Value = "" Then
Cells(linha, 2).Value = Time 'Entrada
ElseIf Cells(linha, 3).Value = "" Then
Cells(linha, 3).Value = Time 'Saída Almoço
ElseIf Cells(linha, 4).Value = "" Then
Cells(linha, 4).Value = Time 'Retorno Almoço
ElseIf Cells(linha, 5).Value = "" Then
Cells(linha, 5).Value = Time 'Saída
Else
MsgBox "Todos os horários deste dia já foram marcados."
End If
Cells(linha, 2).NumberFormat = "hh:mm"
Cells(linha, 3).NumberFormat = "hh:mm"
Cells(linha, 4).NumberFormat = "hh:mm"
Cells(linha, 5).NumberFormat = "hh:mm"
End Sub
mas não estou sabendo inseri-lo na planilha...
alguem para explicar?
Postado : 17/11/2025 9:46 pm