Quick Question

msfatman

Board Regular
Joined
Apr 10, 2008
Messages
110
I'm using this code to save a file:-

fName = Range("Q2").Value
ActiveWorkbook.SaveAs Filename:=sPath & "Issue " & fName & ".xls"

If Q2 has a value in of 4, it saves it as Issue 4, I need it to save as Issue 004. If 5 was entered then it would be Issue 005.

Can anyone help?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
So if it was 14 would it then be 014?

If so maybe try:

Code:
fName = Range("Q2").Value
ActiveWorkbook.SaveAs Filename:=sPath & "Issue " & format(fName,"000") & ".xls"
Otherwise if it would be 0014 then use:

Code:
fName = Range("Q2").Value
ActiveWorkbook.SaveAs Filename:=sPath & "Issue 00" & fName & ".xls"
Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

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