+ Reply to Thread
Results 1 to 3 of 3

Paste into new workbook and save as depending on folders contents

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Paste into new workbook and save as depending on folders contents

    I need a macro that copies all data on sheet1 in my open workbook and then opens a new workbook and pastes special as text into the new workbook. I then need it to save the new workbook as TigerX Csv file where x is a number. I need the number x to be determined by looking in a folder where there are already Tiger1 Tiger2 etc etc files and if the last number used was 2 then it would be saved as csv Tiger3. Any ideas??

  2. #2
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Paste into new workbook and save as depending on folders contents

    Sub macro1()
    
    Dim wb As Workbook
    Dim FileOpen
    Application.DisplayAlerts = False
    
    Set wb = ThisWorkbook
    
    Workbooks.Add
    
    wb.Sheets("Sheet1").UsedRange.Copy Sheets("Sheet1").Range("A1")
    
    
    ChDir "C:\Macro\Tests"
        ActiveWorkbook.SaveAs Filename:="C:\Macro\Tests\TigerX.csv", _
            FileFormat:=xlCSV, CreateBackup:=False
    
    ActiveWorkbook.Close False
    
    Application.DisplayAlerts = True
    
    End Sub
    I have the above which copies what I want, opens a new workbook and saves the new workbook as TigerX.csv but I need the X to change based on what is already in the folder. If the folder already has Tiger1.csv and Tiger2.csv I need this file to be saved as Tiger3.csv
    Last edited by ScabbyDog; 01-09-2013 at 03:39 PM.

  3. #3
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Paste into new workbook and save as depending on folders contents

    Any way of writing a macro to check last used number in a specific folder?

+ 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