Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write macro for entering mm/yy where it fills to current mm/yy
I would like to be able to enter mm/yy in cell a2, and then run a macro that
will fill a3 .... to current mm/yy ... how would I write that? Thanks! Annette |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write macro for entering mm/yy where it fills to current mm/yy
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub If Target.Address = "$A$2" Then On Error GoTo errHandler Application.EnableEvents = False If IsDate(Target) Then i = 0 Do If Month(Target.Offset(i, 0)) = Month(Date) _ And Year(Target.Offset(i, 0)) = Year(Date) Then Exit Sub Else Target.Offset(i + 1, 0).Value = _ DateSerial(Year(Target.Offset(i, 0)), _ Month(Target.Offset(i, 0)) + 1, 1) Target.Offset(i + 1, 0).NumberFormat = _ "mm/yy" i = i + 1 End If Loop While True End If End If errHandler: Application.EnableEvents = True End Sub Right click on the sheet tab of the sheet where you want this behavior and select view code. Paste in code similar to the above. -- Regards, Tom Ogilvy "Annette" wrote in message ... I would like to be able to enter mm/yy in cell a2, and then run a macro that will fill a3 .... to current mm/yy ... how would I write that? Thanks! Annette |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro that Fills Sequential numbers | Excel Worksheet Functions | |||
entering 1 cell fills the worksheet | Excel Worksheet Functions | |||
Automatic Fills Applied To Cells After Entering a Number | Excel Discussion (Misc queries) | |||
Any quick key for entering Current Date and Time? | Excel Worksheet Functions | |||
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? | Excel Worksheet Functions |