Insert Spaces in SaveAs Filename

VinceF

Board Regular
Joined
Sep 22, 2007
Messages
189
Office Version
  1. 2016
Platform
  1. Windows
Greetings,
Hopefully a simple one. I've searched here and the web but couldn't find an answer.
I'm using the code below to save the results of a golf round.
As it is now the saved file looks like this... WED, NOV, 06QUOTA & SKINSROUND#2.XLSM

I'd like to have it look like this...WED, NOV 06 QUOTA & SKINS ROUND#2.XLSM (note the space between the date and the game type and between the game type and the round#2)
Ideally instead of a space there'd be a dash (-) but I don't think special characters are allowed, are they??

Sub SaveWithTodaysDate()
ActiveWorkbook.SaveAs ("C:\Golf\Indianwood\Results\" & ThisWorkbook.Sheets("Main").Range("AL2").Value & ThisWorkbook.Sheets("Main").Range("O2").Value & ThisWorkbook.Sheets("Main").Range("AI3").Value & ThisWorkbook.Sheets("Main").Range("AK3").Value & ".xlsm")

End Sub

Thank You,
VinceF
Office 2016
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Where are the commas coming from? Can you post the actual contents of AL2, O2, AI3 and AK3?
Mumps...Thanks for your assistance..

AL2 is the date and it comes from a helper cell with this formula... =UPPER(TEXT(AQ18,"Ddd, Mmm, DD")) I can and have since simply removed the comma's and it looks cleaner now.
O2 is text and is the name of the game that is being played... it could read Quota, Quota & Skins, or just Skins
AI3 is again text and it reads Round#
AK3 is a number in the cell representing the round#

The is what the saved file name looks like now.
THU NOV 07Quota & SkinsRound#10

The is how I'd like it to look.
THU NOV 07 Quota & Skins Round#10

My desire to insert the spaces is trivial...but I can be a bit anal...plus I would learn more about how this amazing Excel works.

thanks
VinceF
 
Upvote 0
Try:
VBA Code:
Sub SaveWithTodaysDate()
    With Sheets("Main")
        ActiveWorkbook.SaveAs ("C:\Golf\Indianwood\Results\" & .Range("AL2").Value & " " & .Range("O2").Value & " " & .Range("AI3").Value & .Range("AK3").Value & ".xlsm")
    End With
End Sub
 
Upvote 0
Solution
Try:
VBA Code:
Sub SaveWithTodaysDate()
    With Sheets("Main")
        ActiveWorkbook.SaveAs ("C:\Golf\Indianwood\Results\" & .Range("AL2").Value & " " & .Range("O2").Value & " " & .Range("AI3").Value & .Range("AK3").Value & ".xlsm")
    End With
End Sub
Mumps...That did the trick...exactly as I had hoped...very much appreciated....!
VinceF
 
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,019
Members
452,542
Latest member
Bricklin

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