Copy a worksheet to new workbook and name the new workbook

rammergu

New Member
Joined
Oct 17, 2006
Messages
8
Hello,

I'm using Excel 2013.

I'm hoping you can help me achieve the following outcome using macro:

1) Copy current worksheet and create a new workbook.
2) this newly created workbook much be identical to the source worksheet, except there should be no formulae (content and formatting identical to source worksheet a).
3) in the source worksheet, cell A1 is date and cell B1 is customer name. I want the newly created workbook to be saved to my desktop using the content of cells A1 and B1 with an underscore separating the two strings.
eg: 20171202_JohnWest.xlsx

appreciate your kind assistance with this query and thank you in advance.

best regards,
ram
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Try
Code:
Sub SaveAsNewWB()    
Dim MyPath As String
Dim wbName As String
    
MyPath = Environ("USERPROFILE") & "\Desktop\"
    
With ActiveSheet
    wbName = .Cells(1, 1).Value & "_" & .Cells(1, 2).Value
    .Copy
End With


With ActiveWorkbook
    With .Sheets(1).UsedRange.Cells
        .Value = .Value
    End With


    .SaveAs (MyPath & wbName & ".xlsx")
End With


End Sub
 
Upvote 0
Thank you Misca. This works as desired. sincerely appreciate it.


Try
Code:
Sub SaveAsNewWB()    
Dim MyPath As String
Dim wbName As String
    
MyPath = Environ("USERPROFILE") & "\Desktop\"
    
With ActiveSheet
    wbName = .Cells(1, 1).Value & "_" & .Cells(1, 2).Value
    .Copy
End With


With ActiveWorkbook
    With .Sheets(1).UsedRange.Cells
        .Value = .Value
    End With


    .SaveAs (MyPath & wbName & ".xlsx")
End With


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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