PDA

View Full Version : Solved: need space in titled saveas



ndendrinos
03-13-2010, 01:47 PM
This code works
If in B8 I type "Toyota"
and in F6 I type "1234"
a new WB titled Toyota1234 is saved on my desktop.

I need a space between Toyota and 1234
The save as name will be Toyota 1234

Thank you


Sub Email()
Application.ScreenUpdating = False

Worksheets("Invoice").Range("A2:F45").Copy
Worksheets("Your Invoice").Activate
Worksheets("Your Invoice").Range("A2").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Dim newFile As String
Dim ms As String
ms = [B8] & "" & [f6].Value
newFile = ms


strPath = ThisWorkbook.Path
ThisWorkbook.ActiveSheet.Copy
ActiveWorkbook.SaveAs fileName:=strPath & "\" & newFile


Dim Links As Variant
Dim i As Integer
With ActiveWorkbook
Links = .LinkSources(xlExcelLinks)
If Not IsEmpty(Links) Then
For i = 1 To UBound(Links)
.BreakLink Links(i), xlLinkTypeExcelLinks
Next i
End If
End With

[A1].Select


ActiveWorkbook.Save
ActiveWorkbook.Close

Worksheets("Invoice").Activate
ActiveWorkbook.Save
MsgBox prompt:="Done"

Application.ScreenUpdating = True
End Sub

lucas
03-13-2010, 02:20 PM
Put a space between the quotes
ms = [B8] & " " & [f6].Value

ndendrinos
03-13-2010, 04:32 PM
It worked with thanks
Thought the & "" & in

ms = [B8] & "" & [f6].Value
meant that.... wonder what & "" & as opposed to & " " & means then.

lucas
03-13-2010, 05:28 PM
It means empty string. For instance checking a textbox.value for empty.


if txtbox1.value = "" then
msgbox "you must enter some text"

for validation that something has been entered.

ndendrinos
03-13-2010, 05:45 PM
Whoever invented VBA must have been a very lonely child.
Thanks again