Save a selected range as script

sambuddy

New Member
Joined
Oct 16, 2019
Messages
2
it is obvious I do not know what I am doing. What I am trying to accomplish is by pressing the button, Range A1:A12 on sheet called DATA_1 which I set it to be as "ssheet2" be saved on desktop as DATA_1.scr

but executing this macro will change my workbook name to DATA_1. Could anyone please help?

Also how can I ask the saved script file to be on any user desktop and not particular to mine, so I could share the excel file to different users and by executing the macro, the DATA_1.scr generates on their desktop. is there a generic way to formulate that?

Also is there a way to overwrite if there are existing files with the same name on anyone`s desktop without asking any question - if exists just overwrite.
thanks

Private Sub bt2_Click() Set ssheet2 = ThisWorkbook.Sheets("DATA_1")
Range("A1:A12").Select
ssheet2.SaveAs Filename:="C:\Users\sambuddy\Desktop\DATA_1.scr", _
FileFormat:=xlUnicodeText, CreateBackup:=False


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

Forum statistics

Threads
1,224,816
Messages
6,181,139
Members
453,021
Latest member
Justyna P

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