Compile Error: Expected end of statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got a Select Case function like this:

Public Function AcctClass2(GLAccount As String)

Select Case GLAccount
Case 100010 To 100037, 102242, 102250, 102280, 10231X
AcctClass2 = "Cash"

GLAccount is a text field that I'm feeding to this function as an argument.
It doesn't like the X at the end of the Case line, and I get a compile error.
How do I handle this statement to include the X?
 
I've got a Select Case function like this:

Public Function AcctClass2(GLAccount As String)

Select Case GLAccount
Case 100010 To 100037, 102242, 102250, 102280, 10231X
AcctClass2 = "Cash"

GLAccount is a text field that I'm feeding to this function as an argument.
It doesn't like the X at the end of the Case line, and I get a compile error.
How do I handle this statement to include the X?

Try enclosing the GLAccount values in "double quotes" so they'll be
treated as strings rather than numbers.

John W. Vinson[MVP]
 
I knew it was something simple. Thanks!

John Vinson said:
Try enclosing the GLAccount values in "double quotes" so they'll be
treated as strings rather than numbers.

John W. Vinson[MVP]
 
Your missing the END SELECT

Select Case myValue
Case "hello"
Case "foobar"
Case else
End Select

Its a VERY good idea to get into the habit of immediately closing a
statement when required when you open it, BEFORE you write any code. So
if you're writing a Select Case, you would type

Select Case
End Select

right off the bat.

Am I the only or are there others that thing that it would be a great
addition to VBA for VBA to automatically close a statement when needed,
in the same way that typing Sub or Function automatically adds the End
Sub or End Function statements

David H
 
Back
Top