VBA code needed

G

Guest

Guest
Hi,
i made some excel sheet that i need to save often (after changes) under another name, and that name always depends on cell A1 and cell B3. So i've thought to make some vba button assigned as let us say SAVE, which will save document like <value A1>-<valueB3>.xls when clicked. I know how to draw button (heh, like using tools is hard :wink:) but what code should i enter for that button so that it saves my document under name as described?

ty very much
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
If your cells A1 and B3 are on the first worksheet and the command button has the default name, the following will save it as a combination of those cells, with a space in the middle, into the current directory. Hope this is what you meant :): -

Private Sub CommandButton1_Click()

On Error GoTo ErrTrap

ThisWorkbook.SaveAs Worksheets(1).Range("A1") & " " & Worksheets(1).Range("B3")

Exit Sub

ErrTrap:
MsgBox "Unable to save under that filename"

End Sub
This message was edited by Mudface on 2002-03-04 12:14
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,995
Members
448,539
Latest member
alex78

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