little help with code please.... lenze?

dandetroit

New Member
Joined
Sep 16, 2002
Messages
15
I am a novice at code and need a little help to complete the code below. Please indicate what information I need to fill in to complete the code. Thank you! PS... I don't need to password protect.


Sub NameBook()

Dim MyName
MyName = ActiveCell.Text

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

End Sub
 

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"

gnaga

Well-known Member
Joined
Jul 9, 2002
Messages
723
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Sub Save_Book()

Dim MyName

MyName = Activecell
FileName = "C:MyFolder" & MyName
ActiveWorkBook.SaveAs (FileName)

End Sub

Try this code

GNaga
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
On 2002-09-17 07:26, dandetroit wrote:
I am a novice at code and need a little help to complete the code below. Please indicate what information I need to fill in to complete the code. Thank you! PS... I don't need to password protect.


Sub NameBook()

Dim MyName
MyName = ActiveCell.Text

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

End Sub

The code here will save the file with the name of the contents of the active cell. You need to change MyFolder to the directory you use on your computer. If you will always have the desired name in the same cell, say $A$1, then you can subsititute ActiveCell.Text with Range("$A$1")

The second sub I posted will negate the need to hard code a directory and will prompt for one when you save using the macro. Note: neither code runs when you select save on the menu bar. you must actively run the macro from the Macro menu or from a custom button or shortcut key.

HTH
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,524
Messages
5,832,261
Members
430,122
Latest member
SeveretTF

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