+ Reply to Thread
Results 1 to 10 of 10

Problem "save as" in a workbook with a macro

  1. #1
    Registered User
    Join Date
    08-03-2015
    Location
    Australia
    MS-Off Ver
    Excel 97-2003
    Posts
    5

    Problem "save as" in a workbook with a macro

    Hi all,

    New to this forum

    The macro i am trying to create is a form control button in a "Template worksheet" that copies and pastes a client list from a "Master list" to the "Template worksheet" to update the client list. The problem i am having is when the worksheet is saved as a different file name (it is needed) the macro doesn't recognize the "Move back to master file" command as I have the original file name there. Is there a way around this so that I can save this file as a different name and still get the macro to work?

    This is the current macro i have:

    Please Login or Register  to view this content.
    Last edited by excelsoil; 08-03-2015 at 08:50 PM. Reason: wrong code

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem "save as" in a workbook with a macro

    OP Complied with request
    Last edited by humdingaling; 08-03-2015 at 08:52 PM. Reason: Withdrawn by Hum
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    08-03-2015
    Location
    Australia
    MS-Off Ver
    Excel 97-2003
    Posts
    5

    Re: Problem "save as" in a workbook with a macro

    All fixed sorry

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem "save as" in a workbook with a macro

    is this part of some bigger code?
    filetype and filepath is not declared

    also what is
    Workbooks("Agg-0001 -July15 V - Particle Density Coarse Aggregate - Do not use - new lookup").Activate
    is this the workbook itself?

  5. #5
    Registered User
    Join Date
    08-03-2015
    Location
    Australia
    MS-Off Ver
    Excel 97-2003
    Posts
    5

    Re: Problem "save as" in a workbook with a macro

    No this is the code that works when the button is pressed on the "Template worksheet" which on this template the file name is currently "Agg-0001 -July15 V - Particle Density Coarse Aggregate - Do not use - new lookup" when i save this file as a different name this doesn't work because it's trying to revert back to this file name not the new one

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem "save as" in a workbook with a macro

    why not set variable for activeworkbook or thisworkbook?

  7. #7
    Registered User
    Join Date
    08-03-2015
    Location
    Australia
    MS-Off Ver
    Excel 97-2003
    Posts
    5

    Re: Problem "save as" in a workbook with a macro

    Where would i place this into the code and how to word it. Sorry I'm kinda new at VBA.

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem "save as" in a workbook with a macro

    depends on where you run the code
    if the code is the master file itself then
    this code should work
    Please Login or Register  to view this content.
    if the code is run when the workbook is active
    set variable up earlier in piece
    Please Login or Register  to view this content.
    ps outputcol should be column?

    also your copy range is A to N but your outputcol only increments 1...so some overwriting will happen
    is that by design?

  9. #9
    Registered User
    Join Date
    08-03-2015
    Location
    Australia
    MS-Off Ver
    Excel 97-2003
    Posts
    5

    Re: Problem "save as" in a workbook with a macro

    OMG you sir are awesome. You don't realize how much time you will save me. The first code worked perfectly. I just didn't know what to call it so i put the file name there.

  10. #10
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem "save as" in a workbook with a macro

    just some extra optimisation

    with this
    Please Login or Register  to view this content.
    if you only need one column you can do A1:A500
    otherwise change this
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    also
    this may also help streamline if you getting pop up message asking for confirmation

    Please Login or Register  to view this content.
    turn off before loop and turn on after
    Attached Files Attached Files
    Last edited by humdingaling; 08-04-2015 at 01:49 AM. Reason: attached file for reference

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Problem running "Save macro to all workbook in folder"
    By calvinle in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2014, 12:49 AM
  2. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  3. Create a Command Button to "Save As" and "Close" an Excel Workbook
    By thedunna in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-26-2013, 05:38 PM
  4. [SOLVED] Need a save and close macro that does not care if the "edit workbook" button has be clcked
    By rt3 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-22-2013, 08:42 AM
  5. [SOLVED] "Stuck" - Macro to Save Workbook
    By Inez15 in forum Excel General
    Replies: 6
    Last Post: 12-04-2012, 02:14 PM
  6. [SOLVED] Macro to get worksheets to save to new workbook with OPEN workbooks .PATH & " " as name.
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2012, 08:07 PM
  7. save and restore "Workbook Menu Bar" & "Cell" menus
    By Jeff Higgins in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2005, 10:08 PM

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