ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding spaces between ranges with save as macro (https://www.excelbanter.com/excel-programming/435590-adding-spaces-between-ranges-save-macro.html)

John D Inkster

Adding spaces between ranges with save as macro
 
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

Dave Peterson

Adding spaces between ranges with save as macro
 

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.

John D Inkster wrote:

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


--

Dave Peterson

JLatham

Adding spaces between ranges with save as macro
 
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"


"John D Inkster" wrote:

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


John D Inkster[_2_]

Adding spaces between ranges with save as macro
 
Works great! Thanks

"JLatham" wrote:

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"


"John D Inkster" wrote:

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



All times are GMT +1. The time now is 05:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com