+ Reply to Thread
Results 1 to 8 of 8

filename in macro

  1. #1
    ynissel
    Guest

    filename in macro

    whats the syntax to save a file in a macro but use the file from within a cell
    i.e. if cell A1 is the name I want to save the file as - how do I reference
    that cell from within the macro?


  2. #2
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    Try this:

    Please Login or Register  to view this content.
    Change the variable pathName to suit your needs.

    HTH

    Martin
    Martin Short

  3. #3
    Bob Phillips
    Guest

    Re: filename in macro

    Activeworkbook.SAveAs Filename = Worksheets("Sheet1").Range("A1")

    --

    HTH

    Bob Phillips

    (replace xxxx in the email address with gmail if mailing direct)

    "ynissel" <[email protected]> wrote in message
    news:[email protected]...
    > whats the syntax to save a file in a macro but use the file from within a

    cell
    > i.e. if cell A1 is the name I want to save the file as - how do I

    reference
    > that cell from within the macro?
    >




  4. #4
    Gary''s Student
    Guest

    RE: filename in macro

    Let's put qwerty.xls in cell A1. Then:

    Sub Macro1()
    ChDir "C:\"
    ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
    End Sub

    will do a save_as to your top-level directory.
    --
    Gary''s Student


    "ynissel" wrote:

    > whats the syntax to save a file in a macro but use the file from within a cell
    > i.e. if cell A1 is the name I want to save the file as - how do I reference
    > that cell from within the macro?
    >


  5. #5
    ynissel
    Guest

    RE: filename in macro

    this is great - thanks! what would the syntax be if the range I want to name
    is in a sheet called backup and the cell is A15?
    Thanks again.

    "Gary''s Student" wrote:

    > Let's put qwerty.xls in cell A1. Then:
    >
    > Sub Macro1()
    > ChDir "C:\"
    > ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
    > End Sub
    >
    > will do a save_as to your top-level directory.
    > --
    > Gary''s Student
    >
    >
    > "ynissel" wrote:
    >
    > > whats the syntax to save a file in a macro but use the file from within a cell
    > > i.e. if cell A1 is the name I want to save the file as - how do I reference
    > > that cell from within the macro?
    > >


  6. #6
    Bob Phillips
    Guest

    Re: filename in macro

    Activeworkbook.SAveAs Filename = Worksheets("backup").Range("A15")


    --

    HTH

    Bob Phillips

    (replace xxxx in the email address with gmail if mailing direct)

    "ynissel" <[email protected]> wrote in message
    news:[email protected]...
    > this is great - thanks! what would the syntax be if the range I want to

    name
    > is in a sheet called backup and the cell is A15?
    > Thanks again.
    >
    > "Gary''s Student" wrote:
    >
    > > Let's put qwerty.xls in cell A1. Then:
    > >
    > > Sub Macro1()
    > > ChDir "C:\"
    > > ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
    > > End Sub
    > >
    > > will do a save_as to your top-level directory.
    > > --
    > > Gary''s Student
    > >
    > >
    > > "ynissel" wrote:
    > >
    > > > whats the syntax to save a file in a macro but use the file from

    within a cell
    > > > i.e. if cell A1 is the name I want to save the file as - how do I

    reference
    > > > that cell from within the macro?
    > > >




  7. #7
    ynissel
    Guest

    Re: filename in macro

    What am I doing wrong?
    my macro reads:
    ChDir "S:\Underwriting\Secondary\Wholesale\WS Rate Sheets"
    ActiveWorkbook.SaveAs Filename = Worksheets("Rate Sheet Backup").Range("A31")

    Cell A31 reads:
    ="AFC Wholesale Rate Sheet
    "&MONTH(TODAY())&"-"&DAY(TODAY())&"-"&YEAR(TODAY())

    and Im getting a file name of false? when the macro runs.
    Thanks again,
    Yosef

    "Bob Phillips" wrote:

    > Activeworkbook.SAveAs Filename = Worksheets("backup").Range("A15")
    >
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (replace xxxx in the email address with gmail if mailing direct)
    >
    > "ynissel" <[email protected]> wrote in message
    > news:[email protected]...
    > > this is great - thanks! what would the syntax be if the range I want to

    > name
    > > is in a sheet called backup and the cell is A15?
    > > Thanks again.
    > >
    > > "Gary''s Student" wrote:
    > >
    > > > Let's put qwerty.xls in cell A1. Then:
    > > >
    > > > Sub Macro1()
    > > > ChDir "C:\"
    > > > ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
    > > > End Sub
    > > >
    > > > will do a save_as to your top-level directory.
    > > > --
    > > > Gary''s Student
    > > >
    > > >
    > > > "ynissel" wrote:
    > > >
    > > > > whats the syntax to save a file in a macro but use the file from

    > within a cell
    > > > > i.e. if cell A1 is the name I want to save the file as - how do I

    > reference
    > > > > that cell from within the macro?
    > > > >

    >
    >
    >


  8. #8
    Bob Phillips
    Guest

    Re: filename in macro

    ChDir "S:\Underwriting\Secondary\Wholesale\WS Rate Sheets"
    ActiveWorkbook.SaveAs Filename:=Worksheets("Rate Sheet Backup").Range("A31")

    --

    HTH

    Bob Phillips

    (replace xxxx in the email address with gmail if mailing direct)

    "ynissel" <[email protected]> wrote in message
    news:[email protected]...
    > What am I doing wrong?
    > my macro reads:
    > ChDir "S:\Underwriting\Secondary\Wholesale\WS Rate Sheets"
    > ActiveWorkbook.SaveAs Filename = Worksheets("Rate Sheet

    Backup").Range("A31")
    >
    > Cell A31 reads:
    > ="AFC Wholesale Rate Sheet
    > "&MONTH(TODAY())&"-"&DAY(TODAY())&"-"&YEAR(TODAY())
    >
    > and Im getting a file name of false? when the macro runs.
    > Thanks again,
    > Yosef
    >
    > "Bob Phillips" wrote:
    >
    > > Activeworkbook.SAveAs Filename = Worksheets("backup").Range("A15")
    > >
    > >
    > > --
    > >
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (replace xxxx in the email address with gmail if mailing direct)
    > >
    > > "ynissel" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > this is great - thanks! what would the syntax be if the range I want

    to
    > > name
    > > > is in a sheet called backup and the cell is A15?
    > > > Thanks again.
    > > >
    > > > "Gary''s Student" wrote:
    > > >
    > > > > Let's put qwerty.xls in cell A1. Then:
    > > > >
    > > > > Sub Macro1()
    > > > > ChDir "C:\"
    > > > > ActiveWorkbook.SaveAs Filename:="C:\" & Cells(1, 1).Value
    > > > > End Sub
    > > > >
    > > > > will do a save_as to your top-level directory.
    > > > > --
    > > > > Gary''s Student
    > > > >
    > > > >
    > > > > "ynissel" wrote:
    > > > >
    > > > > > whats the syntax to save a file in a macro but use the file from

    > > within a cell
    > > > > > i.e. if cell A1 is the name I want to save the file as - how do I

    > > reference
    > > > > > that cell from within the macro?
    > > > > >

    > >
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1