Save As Macro Help

Aaron

Board Regular
Joined
Feb 20, 2002
Messages
237
I have the following code in a macro, and it worked once, and now will not. Can anyone offer a suggestion? I appreciate any help.

ActiveWorkbook.SaveAs _
FileName:="D:Personal" & Worksheets("Instructions") _
.Range("DIVLOC").Value & "I.xls", _
FileFormat:=xlNormal, _
Password:="mfgie", _
WriteResPassword:=""
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Well I am trying to name a file off a range name in another Workbook. Any ideas? I am essentially teaching myself VB as I go. I am very new, and liking what I am finding. Thanks for any help you can offer. -asa
 
Upvote 0
Well I have my code working now, but it is naming the file the wrong name. I want it to name what is in Cell A2, and it is naming the file InstructionsI. Thanks for your quick responses.

ActiveWorkbook.SaveAs _
FileName:="D:Personal " & Sheet1.Range("A2").Value & "I.xls", _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:=""
 
Upvote 0
I am now getting a Compile Error with this code. I know it is the weekend, so you guys and gals have a good one. See you all Monday. -asa

ActiveWorkbook.SaveAs _
FileName:="D:Personal &Worksheets("Sheet1").Range("A2").Value & "I.xls", _
FileFormat:=xlNormal, _
Password:="mfgie", _
WriteResPassword:=""
 
Upvote 0
On 2002-04-19 15:19, Aaron wrote:
I am now getting a Compile Error with this code. I know it is the weekend, so you guys and gals have a good one. See you all Monday. -asa

ActiveWorkbook.SaveAs _
FileName:="D:Personal &Worksheets("Sheet1").Range("A2").Value & "I.xls", _
FileFormat:=xlNormal, _
Password:="mfgie", _
WriteResPassword:=""

On that code you're missing the double-quotes after Personal ... should be:

FileName:="D:Personal" & Worksheets ...

Sorry, am trying to get work finished here as I'm out next week. It looks like your code should work - what's in cell A2?
 
Upvote 0
Cell A2 is what I want my File name to be. I also have a string that I could use in cell A6, that I could use the first five Characters. Would I use the LEFT command like on a worksheet? Many thanks for all of your help. -asa
 
Upvote 0

Forum statistics

Threads
1,214,385
Messages
6,119,208
Members
448,874
Latest member
b1step2far

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