Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding spaces John K Excel Discussion (Misc queries) 5 April 8th 10 03:49 PM
Adding spaces into a variable Peter[_61_] Excel Programming 4 December 18th 06 10:29 AM
Adding Spaces to the end of a value JohnGuts Excel Worksheet Functions 4 July 30th 06 09:50 PM
Removing spaces and adding comma's using a Macro Jeroen[_2_] Excel Programming 2 May 24th 06 10:50 AM
Adding leading spaces [email protected] Excel Programming 7 February 24th 06 06:18 PM


All times are GMT +1. The time now is 06:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"