Macro code to English translation
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Macro code to English translation

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    Northampton, UK
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    London, UK
    Posts
    167
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.


    _________________

    DALEY :P


    [ This Message was edited by: daleyman on 2002-04-14 07:34 ]

  3. #3
    New Member
    Join Date
    Mar 2002
    Location
    Northampton, UK
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #4
    Board Regular
    Join Date
    Mar 2002
    Location
    London, UK
    Posts
    167
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    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

    _________________

    DALEY :P


    [ This Message was edited by: daleyman on 2002-04-14 08:20 ]

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com