Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 9 of 9

Thread: save my files as....

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    hey,

    i am writing a macro to save my monthly sale summarys at the end of each month, however, the problem is that i cannot save the files as diffrent names each time, is this possible and if so how? Any help is great, thanx alot

    Craig

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    how would you like th efile name to be :

    loklk at it like in parts .. or just wack the time on the end never two the same then


    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-25 10:49, Craig AS wrote:
    hey,

    i am writing a macro to save my monthly sale summarys at the end of each month, however, the problem is that i cannot save the files as diffrent names each time, is this possible and if so how? Any help is great, thanx alot

    Craig
    Sure its possible. But what do you want to name them? You can get a name out of a cell and add an extension. For example:

    sFileName = ActiveSheet.Range("A1").text & ".xls"


  4. #4
    New Member
    Join Date
    Mar 2002
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    thnx,

    i will want to name them the month and then year, eg. april 2001, may 2001...etc

    can this still be used with the formula u gave me?


  5. #5
    Board Regular
    Join Date
    Feb 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-25 11:20, Craig AS wrote:
    thnx,

    i will want to name them the month and then year, eg. april 2001, may 2001...etc

    can this still be used with the formula u gave me?

    Did you want to name them by the current month, or are you doing work on previous months? If it is the current month, do this in VBA: (fname is the variable where the filename string will be stored)


    fname = MonthName(Month(Now)) & Year(Now)


    If you want to name it according to past
    months, you need the name of the month and
    year to be extracted from somewhere. Lets
    say you keep the date in A1 for each sheet
    you are saving, do this:


    Dim old_date As Date
    Dim File_Name as String
    old_date = Worksheets("sheet1").Range("A1").Value
    File_Name = MonthName(Month(old_date)) & Year(old_date)





    [ This Message was edited by: John McGraw on 2002-04-25 13:11 ]

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    the codes here adre spot on, but weill not cover your request could clash, thus i gave the answer in my posy admitted not code sugget link else <<<<>> does not answer the quersion...

    see what i mean!


    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  7. #7
    New Member
    Join Date
    Mar 2002
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    hey thnx alot,

    but wud i then just have 2 put some thing like

    Activeworkbook.save as("fname")?

    ne way, i'll give it a go

    thnx again

  8. #8
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    just playing try adding


    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  9. #9
    Board Regular
    Join Date
    Feb 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-25 14:37, Craig AS wrote:
    hey thnx alot,

    but wud i then just have 2 put some thing like

    Activeworkbook.save as("fname")?

    ne way, i'll give it a go

    thnx again
    Yes thats correct, except there is no space between save and as. And you dont put quotes around file_name if it is a variable. Otherwise your file will actually
    be saved as "fname", literaly.


    ActiveWorkbook.Saveas(File_Name)

Some videos you may like

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
  •