View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Daniel.C[_3_] Daniel.C[_3_] is offline
external usenet poster
 
Posts: 133
Default two consecutive maros

Hi.
No you must only have one "Worksheet_Change" macro. Try :

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
If Target.Address(False, False) = "B5" Then
Range("C1").Value = IIf(IsEmpty(Target), "", "" &
UCase(Format(Date, "dddd dd.mm.yyyy")))
ElseIf Target.Cells.Column = 1 And Target.Cells.Row = 5 Then
Application.EnableEvents = False
N = Target.Row
If Me.Range("A" & N).Value < "" Then
With Me.Range("B" & N)
If .Value = "" Then
..Value = Now
End If
End With
End If
Application.EnableEvents = True
End If
enditall:
End Sub

HTH
Daniel

Hi, can this two macro codes work in the same sheet? Both codes are working
separately, but not together.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "B5" Then _
Range("C1").Value = IIf(IsEmpty(Target), "", "" &
UCase(Format(Date, "dddd dd.mm.yyyy")))

End Sub
--------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 And Target.Cells.Row = 5 Then
N = Target.Row
If Me.Range("A" & N).Value < "" Then
With Me.Range("B" & N)
If .Value = "" Then
.Value = Now
End If
End With
End If
End If
enditall:
Application.EnableEvents = True
End Sub


Thanks!