PC Review


Reply
Thread Tools Rate Thread

Adding spaces between ranges with save as macro

 
 
John D Inkster
Guest
Posts: n/a
 
      30th Oct 2009
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 With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      30th Oct 2009

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
 
Reply With Quote
 
JLatham
Guest
Posts: n/a
 
      30th Oct 2009
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 With Quote
 
John D Inkster
Guest
Posts: n/a
 
      30th Oct 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB Macro Code to Save Excel Ranges in Access Tables =?Utf-8?B?UmFqZXNo?= Microsoft Excel Discussion 1 12th Mar 2007 10:48 AM
Adding Spaces to the end of a value JohnGuts Microsoft Excel Worksheet Functions 4 30th Jul 2006 09:50 PM
Removing spaces and adding comma's using a Macro =?Utf-8?B?SmVyb2Vu?= Microsoft Excel Programming 2 24th May 2006 10:50 AM
Adding Spaces DS Microsoft Access 8 28th Apr 2005 03:42 PM
Saving XL ranges as Fixed Field Length Text - Leading spaces AS Microsoft Excel Programming 2 17th Mar 2005 08:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:50 AM.