Excel 2010 Macro Save AS

robert222

New Member
Joined
Mar 25, 2011
Messages
3
Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> </o:p>Can anyone help, I am looking for a macro that once run will a copy of the workbook with a name based on the contents of cell AL61 on a sheet named MAIN SHEET but allow the user to specify the path.<o:p></o:p>
I have very little experience with programing. Can anyone help.<o:p></o:p>
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Code:
Private Sub cmdGetSaveAsName_Click()
Dim save_as As Variant
Dim file_name As String

file_name = Sheets("MAIN SHEET").Range("AL61")

    ' Get the file name.
    save_as = Application.GetSaveAsFilename(file_name, _
        FileFilter:="Excel Files,*.xls,All Files,*.*")
    ' See if the user canceled.
    If save_as = False Then Exit Sub

    ' Save the file with the new name.
    If LCase$(Right$(save_as, 4)) <> ".xls" Then
        file_name = save_as & ".xls"
    End If
    ActiveWorkbook.SaveAs Filename:=save_as
End Sub
 
Upvote 0
Thanks you

That seems to work but does not add a file extension when it saves.

Is there a way to have it save with a .xls or .xlsm extension.

Regards

Robert
 
Upvote 0
Hello,
When I use this code .xlsm to the actual file name. What do I need to do to stop that from being added?
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,517
Members
448,968
Latest member
Ajax40

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