variables in save as code

SlinkRN

Well-known Member
Joined
Oct 29, 2002
Messages
711
Hi,
I want to create a macro that will allow the user to enter a month, day, and year into a userform and then use those variables in the pathway to save as a new file.
I figured it out with the variables, but I can't figure out how to put spaces between the variables.

Here's the code I have that saves it without spaces:

path = "C:\Documents and Settings\Compaq\Desktop\"
activeworkbook.saveas filename"= _
path & "Sched beg" & txtmonth & txtday & txtyear.fileformat:=xlnormal

I tried adding & " " between the variables but that doesn't work.
Thanks, Slink
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi Slink, looks like the syntax needs cleaning up. Try:
Code:
path = "C:\Documents and Settings\Compaq\Desktop\" 
activeworkbook.saveas filename:= _ 
path & "Sched beg" & txtmonth & " " & txtday & " " & txtyear, fileformat:=xlnormal
Denis
 
Upvote 0
Hi Denis,
Thanks, I was SURE I had tried that, but I just tried it again and it works! Who knows what I had done before :rolleyes: Thanks for the reply! Slink
 
Upvote 0

Forum statistics

Threads
1,203,521
Messages
6,055,890
Members
444,831
Latest member
iceonmn

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