Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Automaticaly Enter Date in selected Cell
All,
I am trying to perfect a macro that will, when the word "Reporting" is put in cell D2 enter a date stamp into cell I2. I have got this far after some experimenting but it keeps coming up with an error message. The macro I have so far is, Private Sub Worksheet_Change(ByVal Target As Excel.Range) With Target If .Count 1 Then Exit Sub If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then Application.EnableEvents = False If Target = "Reporting" Then With .Offset(0, 5) .NumberFormat = "dd/mm/yyyy" .Value = Now End With Application.EnableEvents = True End If End With End Sub Any Suggestions? |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Automaticaly Enter Date in selected Cell
You were missing an End If. Try
Private Sub Worksheet_Change(ByVal Target As Excel.Range) With Target If .Count 1 Then Exit Sub If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then If Target = "Reporting" Then On Error Resume Next Application.EnableEvents = False With .Offset(0, 5) .NumberFormat = "dd/mm/yyyy" .Value = Now End With Application.EnableEvents = True End If End If End With End Sub In article , Ceptor54 wrote: All, I am trying to perfect a macro that will, when the word "Reporting" is put in cell D2 enter a date stamp into cell I2. I have got this far after some experimenting but it keeps coming up with an error message. The macro I have so far is, Private Sub Worksheet_Change(ByVal Target As Excel.Range) With Target If .Count 1 Then Exit Sub If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then Application.EnableEvents = False If Target = "Reporting" Then With .Offset(0, 5) .NumberFormat = "dd/mm/yyyy" .Value = Now End With Application.EnableEvents = True End If End With End Sub Any Suggestions? |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Automaticaly Enter Date in selected Cell
Worked perfectly thanks a lot!!!
"JE McGimpsey" wrote: You were missing an End If. Try Private Sub Worksheet_Change(ByVal Target As Excel.Range) With Target If .Count 1 Then Exit Sub If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then If Target = "Reporting" Then On Error Resume Next Application.EnableEvents = False With .Offset(0, 5) .NumberFormat = "dd/mm/yyyy" .Value = Now End With Application.EnableEvents = True End If End If End With End Sub In article , Ceptor54 wrote: All, I am trying to perfect a macro that will, when the word "Reporting" is put in cell D2 enter a date stamp into cell I2. I have got this far after some experimenting but it keeps coming up with an error message. The macro I have so far is, Private Sub Worksheet_Change(ByVal Target As Excel.Range) With Target If .Count 1 Then Exit Sub If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then Application.EnableEvents = False If Target = "Reporting" Then With .Offset(0, 5) .NumberFormat = "dd/mm/yyyy" .Value = Now End With Application.EnableEvents = True End If End With End Sub Any Suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
can excel automatically enter the date data in a cell was entered | Excel Worksheet Functions | |||
to enter today's date if a cell is blank | Excel Worksheet Functions | |||
run a macro in a locked cell | Excel Discussion (Misc queries) | |||
Possible Lookup Table | Excel Worksheet Functions | |||
Changing Cell formats to date fields automatically | Excel Worksheet Functions |