Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
For example:
Sub marie() Dim d As Date Dim n As Integer d = Now n = Month(d) - 1 If n = 0 Then n = 12 Select Case n Case 1 MsgBox ("january") Case 2 MsgBox ("february") Case 3 MsgBox ("march") Case 4 MsgBox ("april") Case 5 MsgBox ("may") Case 6 MsgBox ("june") Case 7 MsgBox ("july") Case 8 MsgBox ("august") Case 9 MsgBox ("september") Case 10 MsgBox ("october") Case 11 MsgBox ("november") Case 12 MsgBox ("december") End Select End Sub When this is run, it will announce the name of the previous month. After the MSGBOX(), include any coding specific for that month. -- Gary's Student gsnu200701 "Marie Bayes" wrote: Thanks Gary's student, but I'm not that clever. I was hoping someone could actually give me the code that would tell me what last month was and then how I could 'jump' to that part of my macro. "Gary''s Student" wrote: Use the CASE statement with separate sections for each month. -- Gary's Student gsnu200701 "Marie Bayes" wrote: I need to run a macro over a year, I would like to set it up at the start of the year but set each part to run dependant on what month I'm in. I always run the report for data entered up to yesterday, ie, if it's the 1st of Feb will be running Jan's macro. Is there a way I can write into the code to call the section just for that month and then at the end of that section continue with the remainder of the macro? Thanks in advance for your help. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro Help (Uppercase multiple ranges?) | Excel Discussion (Misc queries) | |||
run a macro for a selected date | Excel Discussion (Misc queries) | |||
error when running cut & paste macro | Excel Worksheet Functions | |||
insert date | Excel Worksheet Functions | |||
Date macro | Excel Discussion (Misc queries) |