save as = cell

ksmith

New Member
Joined
Oct 8, 2002
Messages
49
I want to save a worksheet by clicking a button that will save the sheet as the text in a certain cell. So the macro would have to save as the text in a cell.
example: cell A1=6315. Save file as 6315.
Any ideas would be great! Thanks!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Sub SaveByCell()
Dim sFileName As String
'Standard module code!
'Cell A1 has the new file name.
sFileName = Sheets("Sheet1").Range("A1")

'If Cell A1 is Blank do not save.
If sFileName = "" Then Exit Sub

'The Drive:Path & the file name in cell A1.
ThisWorkbook.SaveAs "C:MyFilesJSWExcelData" & sFileName
End Sub
 

zacemmel

Well-known Member
Joined
Apr 29, 2002
Messages
636
Nevermind ;p
This message was edited by zacemmel on 2002-10-28 15:39
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Try one of these macros previouly posted on the board.

Sub NameBook()

Dim MyName
MyName = ActiveCell.Text

ActiveWorkbook.SaveAs _
FileName:="C:MyFolder" & MyName, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False

End Sub
or this will let you select directory
Sub NameBook2()
Dim MyName
MyName = ActiveCell.Text
Application.Dialogs(xlDialogSaveAs).Show _
MyName
End Sub

If you want to fix the code to a specific cell, change ActiveCell.Text to Range("$A$1").Text
 

Forum statistics

Threads
1,144,446
Messages
5,724,400
Members
422,550
Latest member
Parvin_B

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
Top