How do I save the worksheet into a new workbook with the file name referencing from Sheet1 C3 via VBA?

Starkers

New Member
Joined
Oct 26, 2021
Messages
14
Office Version
  1. 365
Platform
  1. Windows
How do I save the worksheet into a new workbook with the file name referencing from Sheet1 C3?

Currently this is the vba code that I am using right now.

VBA Code:
Sub Billing_Milestone()

Worksheets("Billing Milestone").Copy
    With ActiveWorkbook
       .SaveAs Filename:= "C:\Users\Desktop" & "Billing Milestone", FileFormat:=xlOpenXMLWorkbook
        .Close savechanges:=False
    End With
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Do you want to use C3 in the Billing Milestones sheet, for the file name?
 
Upvote 0
How do I save the worksheet into a new workbook with the file name referencing from Sheet1 C3?

Currently this is the vba code that I am using right now.

VBA Code:
Sub Billing_Milestone()

Worksheets("Billing Milestone").Copy
    With ActiveWorkbook
       .SaveAs Filename:= "C:\Users\Desktop" & "Billing Milestone", FileFormat:=xlOpenXMLWorkbook
        .Close savechanges:=False
    End With
End Sub
Do you want to use C3 in the Billing Milestones sheet, for the file name?
The filename should be values in C3 (from Sheet1) & “Billing Milestone”
 
Upvote 0
Ok, how about
VBA Code:
Sub Billing_Milestone()
   Dim Fname As String
   Fname = Sheets("Sheet1").Range("C3").Text
Worksheets("Billing Milestone").Copy
    With ActiveWorkbook
       .SaveAs Filename:="C:\Users\Desktop\" & Fname & " Billing Milestone", FileFormat:=xlOpenXMLWorkbook
        .Close savechanges:=False
    End With
End Sub
 
Upvote 0
Ok, how about
VBA Code:
Sub Billing_Milestone()
   Dim Fname As String
   Fname = Sheets("Sheet1").Range("C3").Text
Worksheets("Billing Milestone").Copy
    With ActiveWorkbook
       .SaveAs Filename:="C:\Users\Desktop\" & Fname & " Billing Milestone", FileFormat:=xlOpenXMLWorkbook
        .Close savechanges:=False
    End With
End Sub
Wow, it works. This is nice, thanks for the assist!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top