Results 1 to 10 of 15

Thread: VBA Macro To Create An Excel File With Same Sheet Name As Workbook Name

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    Aug 2012
    Posts
    40
    Rep Power
    0

    VBA Macro To Create An Excel File With Same Sheet Name As Workbook Name

    I have written code to create a csv file, but the sheet name must the same as sheet1 on the xlsm file from whch it was created


    Code:
     Sub CreateCSVFile()
    Dim MyPath As String
    Dim MyFileName As String
    'The path and file names:
    MyPath = "C:\Journal Templates\"
    MyFileName = "Adjustment JNL.csv"
    
        If Not Right(MyPath, 1) = "\" Then MyPath = MyPath & "\"
        
    With ActiveWorkbook
    .Sheets(1).Name = "JNL"
        .SaveAs Filename:= _
            MyPath & MyFileName, _
            FileFormat:=xlCSV, _
            CreateBackup:=False
        
        .Close False
    End With
    End Sub
    Kindly amend my code to meet the above requirement

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://eileenslounge.com/viewtopic.php?p=317218#p317218
    https://eileenslounge.com/viewtopic.php?p=316955#p316955
    https://eileenslounge.com/viewtopic.php?p=316955#p316955
    https://eileenslounge.com/viewtopic.php?p=316940#p316940
    https://eileenslounge.com/viewtopic.php?p=316927#p316927
    https://eileenslounge.com/viewtopic.php?p=317014#p317014
    https://eileenslounge.com/viewtopic.php?p=317006#p317006
    https://eileenslounge.com/viewtopic.php?p=316935#p316935
    https://eileenslounge.com/viewtopic.php?p=316875#p316875
    https://eileenslounge.com/viewtopic.php?p=316254#p316254
    https://eileenslounge.com/viewtopic.php?p=316280#p316280
    https://eileenslounge.com/viewtopic.php?p=315915#p315915
    https://eileenslounge.com/viewtopic.php?p=315512#p315512
    https://eileenslounge.com/viewtopic.php?p=315744#p315744
    https://www.eileenslounge.com/viewtopic.php?p=315512#p315512
    https://eileenslounge.com/viewtopic.php?p=315680#p315680
    https://eileenslounge.com/viewtopic.php?p=315743#p315743
    https://www.eileenslounge.com/viewtopic.php?p=315326#p315326
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40752
    https://eileenslounge.com/viewtopic.php?p=314950#p314950
    https://www.eileenslounge.com/viewtopic.php?p=314940#p314940
    https://www.eileenslounge.com/viewtopic.php?p=314926#p314926
    https://www.eileenslounge.com/viewtopic.php?p=314920#p314920
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 05-20-2024 at 03:39 PM.

Similar Threads

  1. Replies: 4
    Last Post: 07-02-2013, 11:32 AM
  2. Replies: 4
    Last Post: 06-18-2013, 01:38 PM
  3. VBA To Create A New Workbook
    By cdurfey in forum Excel Help
    Replies: 9
    Last Post: 05-23-2013, 06:41 PM
  4. Excel VBA Macro To Open A File Through Browse Dialog Box
    By Safal Shrestha in forum Excel Help
    Replies: 2
    Last Post: 04-05-2013, 12:59 PM
  5. Replies: 1
    Last Post: 06-02-2011, 10:38 AM

Posting Permissions

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