PDA

View Full Version : IsNumber not working



next
02-20-2008, 12:48 PM
For Each x In Range("B:B")
If x.Row > LastCell Then: Exit For
If IsEmpty(x.Value) Then: x.Value = "30"
If IsNumber(x.Value) Then
Select Case (x.Value)
Case 0 To 20: TotalPastDue = TotalPastDue + Range("L" & x.Row) _
- Range("C" & x.Row) - Range("D" & x.Row)
Case 20 To 30: TotalPastDue = TotalPastDue + Range("L" & x.Row) _
- Range("C" & x.Row) - Range("D" & x.Row) - Range("E" & x.Row)
Case 30 To 45: TotalPastDue = TotalPastDue + Range("L" & x.Row) _
- Range("C" & x.Row) - Range("D" & x.Row) - Range("E" & x.Row) - Range("F" & x.Row) _
- Range("G" & x.Row)
Case 45 To 120: TotalPastDue = TotalPastDue + Range("L" & x.Row)
End Select
Next x


For some reason IsNumber brings up an error message saying "Sub or Function not defined.". What am i doing wrong?

next
02-20-2008, 12:55 PM
If statement was causing an error, please delete this thread.
Thanks.

mdmackillop
02-20-2008, 04:54 PM
If you use Option Explicit and compile your code before use, any such errors will be revealed.

Bob Phillips
02-20-2008, 05:13 PM
IsNumber throws a runtime error with or without Option Explicit, so there was enough info there.

mdmackillop
02-20-2008, 05:20 PM
He won't as far as any IsNumber runtime error with the If ... Next code as written.

mikerickson
02-20-2008, 07:31 PM
ISNUMBER is a spreadsheet function.
IsNumeric is a VB function.

next
02-20-2008, 11:24 PM
i thought that "Option Explicit" just forces you to declare all your vars, how will it reveal errors like this one?

IsNumeric is a VB function. VB is so much more complicated than the first language that i learned, i'm going to be making those rookie mistakes for a looooooong time. :banghead:

mdmackillop
02-21-2008, 01:01 AM
i thought that "Option Explicit" just forces you to declare all your vars, how will it reveal errors like this one?

Why not give it a try?

Bob Phillips
02-21-2008, 02:06 AM
He won't as far as any IsNumber runtime error with the If ... Next code as written.

I did.