![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: Northampton, UK
Posts: 33
|
I was wondering if anyone could provide me with an English translation of what the following code means and does step by step?!?! Thanks very much
Dim MyDate Dim MyMonth MyDate = Date MyMonth = Month(MyDate) ThisWorkbook.SaveAs Filename:="Taxi-2-Go - " & MonthName(MyMonth) & Year(Date) End Sub Thanks again, B |
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Mar 2002
Location: London, UK
Posts: 167
|
Dim MyDate
Dim MyMonth ...declares two new variables, for use later... MyDate = Date ...assigns the current date into the variable MyDate... MyMonth = Month(MyDate) ...takes the month, as an integer (whole number) value, from MyDate, and places the value in MyMonth... ThisWorkbook.SaveAs Filename:="Taxi-2-Go - " & MonthName(MyMonth) & Year(Date) ... saves ThisWorkbook as the concatenated file name as stated, ie. take the string "Taxi-2-Go" and append the name of the month (of which the numeric value is in MyMonth, eg. 11=november), and also append the year of the current date... End Sub ...ends the procedure, this is paired with the statement... Sub MyProcedure() ...that you have missed out in your cut & paste but should come at the beginning of the code.. This same code can be done in one statement, as follows... Sub MyRoutine() ThisWorkbook.SaveAs Filename:="Taxi-2-Go - " & MonthName(Month(Date)) & Year(Date) End Sub ...and you can play with it for differing results, for example if you want to insert a space in between the month and the year you would use the following... Sub MyRoutine() ThisWorkbook.SaveAs Filename:="Taxi-2-Go - " & MonthName(Month(Date)) & " " & Year(Date) End Sub ...good luck, don't be afraid to get stuck in and make changes to these things. _________________
[ This Message was edited by: daleyman on 2002-04-14 07:34 ] |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Location: Northampton, UK
Posts: 33
|
Thanks for that, very very helpful!! One quick thing though, I was wondering what the "Dim" stood for or was short for?!?! Thanks, B
|
|
|
|
|
|
#4 | |
|
Board Regular
Join Date: Mar 2002
Location: London, UK
Posts: 167
|
Thinks it stands for Dimension. That is, you are asking the computer to Dimension a Variable, that is, allocate memory space for it. Normally you would specify a type, so that the computer knows how much space to allocate, eg.
Dim MyNumberVariable as Integer Dim MyCharacterString as String Dim MyTrueFalse as Boolean _________________
[ This Message was edited by: daleyman on 2002-04-14 08:20 ] |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|