Adding spaces between ranges with save as macro

J

John D Inkster

This macro works great but I would like it to add spaces between each value
in the saved name, I have tried adding other ranges with a space in the cell
but that didn't work. Any help would be greatly appeciated.

Thanks in advance

John

On Error Resume Next
If Range("t4").Value > 0 _
And Range("u4").Value > 0 _
And Range("v4").Value > 0 _
And Range("f4").Value > " " _
Then


ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & _
ThisWorkbook.Worksheets(1).Range("f4").Value & _
ThisWorkbook.Worksheets(1).Range("t4").Value & _
ThisWorkbook.Worksheets(1).Range("u4").Value & _
ThisWorkbook.Worksheets(1).Range("v4").Value & _
".xls"
MsgBox "Time Card Saved", vbOKOnly + vbExclamation
Else
MsgBox "Date Not Correct, Or Name Not Entered. Time Sheet Not Saved", _
vbOKOnly + vbExclamation

End If
End Sub
 
D

Dave Peterson

ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & _
ThisWorkbook.Worksheets(1).Range("f4").Value & " " & _
ThisWorkbook.Worksheets(1).Range("t4").Value & " " & _
ThisWorkbook.Worksheets(1).Range("u4").Value & " " & _
ThisWorkbook.Worksheets(1).Range("v4").Value & _
".xls"

I didn't put the space after the \ or before the .xls.
 
J

JLatham

Try the SaveAs statement this way:

ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & _
ThisWorkbook.Worksheets(1).Range("f4").Value & _
" " & _
ThisWorkbook.Worksheets(1).Range("t4").Value & _
" " & _
ThisWorkbook.Worksheets(1).Range("u4").Value & _
" " & _
ThisWorkbook.Worksheets(1).Range("v4").Value & _
".xls"
 
J

John D Inkster

Works great! Thanks

JLatham said:
Try the SaveAs statement this way:

ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & _
ThisWorkbook.Worksheets(1).Range("f4").Value & _
" " & _
ThisWorkbook.Worksheets(1).Range("t4").Value & _
" " & _
ThisWorkbook.Worksheets(1).Range("u4").Value & _
" " & _
ThisWorkbook.Worksheets(1).Range("v4").Value & _
".xls"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top