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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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