I can't seem to get this VBA to work...:(


Posted by Ania on January 23, 2002 12:16 PM

can someone please explain to me why DealName in this code does not take more than one word?


Private Sub Workbook_Open()
Dim DealName As String
Do Until DealName <> ""
DealName = InputBox("Enter your Deal File Name:", "Name Your Deal")
Loop
FirstSpace = InStr(DealName, " ")
If FirstSpace <> 0 Then
DealName = Left(DealName, FirstSpace)
End If
Range("$M$3") = DealName
ThisFile = Range("M$3").Value
ActiveWorkbook.SaveAs Filename:="R:\Kondrikova\onQ\WIP\Cla" & ThisFile & ".xls"
End Sub

Posted by Joe Was on January 23, 2002 12:42 PM

Your code:

'If FirstSpace <> 0 Then
'DealName = Left(DealName, FirstSpace)
'End If

is telling your code to stop at the first " " in Deal Name, I commented it out and your code ran fine. JSW

Posted by on January 23, 2002 12:43 PM

Because Do until DealName "" equates to True after the 1st entry (NT)

Posted by Ania on January 23, 2002 2:00 PM

i am new to VB so I have no idea what you mean by commenting it out...

'If FirstSpace <> 0 Then

Posted by Joe Was on January 23, 2002 2:21 PM

Re: i am new to VB so I have no idea what you mean by commenting it out...

You can remove the code I have listed below or you can add a " ' " infront of the lines like I have. JSW

Posted by Jim on January 23, 2002 2:24 PM

Re: i am new to VB so I have no idea what you mean by commenting it out...

Hi Ania,

Take a look at Joes reply and copy it. The commented
out is the ' before your line of code, when you
use a ' before your code vba treats it as a comment

Jim : Your code



Posted by Ania on January 23, 2002 2:45 PM

thanks:)))