Macro code to English translation

Beckwa

New Member
Joined
Mar 12, 2002
Messages
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
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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.


_________________<table style="background-color:#0e54be" cellspacing="1" cellpadding="2"><td style="background-color:#ceffff;font-family:arial;color:#072c63;font-size:8pt;">   DALEY  :P  </td></table>
This message was edited by daleyman on 2002-04-14 07:34
 
Upvote 0
Thanks for that, very very helpful!! One quick thing though, I was wondering what the "Dim" stood for or was short for?!?! Thanks, B
 
Upvote 0
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

_________________<table style="background-color:#0e54be" cellspacing="1" cellpadding="2"><td style="background-color:#ceffff;font-family:arial;color:#072c63;font-size:8pt;">   DALEY  :P  </td></table>
This message was edited by daleyman on 2002-04-14 08:20
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,194
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top