Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro that Fills Sequential numbers David A. Excel Worksheet Functions 3 July 14th 07 07:03 AM
entering 1 cell fills the worksheet CaitlinC Pro Honda Excel Worksheet Functions 1 March 15th 07 09:53 AM
Automatic Fills Applied To Cells After Entering a Number Janet Excel Discussion (Misc queries) 4 February 18th 06 12:02 AM
Any quick key for entering Current Date and Time? Philip Excel Worksheet Functions 2 January 12th 06 04:18 PM
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? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM


All times are GMT +1. The time now is 04:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"