+ Reply to Thread
Results 1 to 5 of 5

Overwrites old files when saving with macro, fix for this? Excel 2010

  1. #1
    Registered User
    Join Date
    12-11-2014
    Location
    Gävleborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    13

    Overwrites old files when saving with macro, fix for this? Excel 2010

    Hi, I have this code, but the problem is that it overwrites a file if it has the same name. How do I make it save the new file for example with a number at the end? Or maybe asks me what I want to do? I'm new to VBA in excel as you may have noticed

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Overwrites old files when saving with macro, fix for this? Excel 2010

    Ok this is what you need.
    Replace the code after this text:

    Please Login or Register  to view this content.
    with my text.



    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-11-2014
    Location
    Gävleborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Overwrites old files when saving with macro, fix for this? Excel 2010

    Quote Originally Posted by mehmetcik View Post
    Ok this is what you need.
    Replace the code after this text:

    Please Login or Register  to view this content.
    with my text.



    Please Login or Register  to view this content.
    Okay thanks but I tried it and got error messages, I'm not sure how to paste it and were. Could you maybe paste the whole code I need? So I can just replace my code, I would be very thankful if you could do that!
    /Axel

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Overwrites old files when saving with macro, fix for this? Excel 2010

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 12-12-2014 at 09:38 AM.

  5. #5
    Registered User
    Join Date
    12-11-2014
    Location
    Gävleborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Overwrites old files when saving with macro, fix for this? Excel 2010

    Quote Originally Posted by mehmetcik View Post
    Private Sub CommandButton1_Click()
    Dim ws As Worksheet
    Dim strPath As String
    Dim myFile As Variant
    Dim strFile As String
    On Error GoTo errHandler

    Please Login or Register  to view this content.
    Okay now I got it working, thank you!

+ 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. [SOLVED] Excel 2010 VB macro to open all files in folder and run a simple macro
    By MSFLNA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2013, 02:54 PM
  2. Replies: 1
    Last Post: 04-20-2013, 07:36 AM
  3. Replies: 1
    Last Post: 02-29-2012, 01:15 PM
  4. Problem saving macro Excel 2007/2010
    By Gio_it in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2011, 06:08 AM
  5. saving an excel file overwrites a file elsewhere??
    By shogun assassin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-23-2009, 01:15 AM

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