Search : in
By :

Determining if a cell value is an integer

Last answer on Mar 4, 2009 9:15:49 pm GMT mtbtweety, on Mar 4, 2009 6:08:44 pm GMT 
 Report this message to moderators

Hello,
I'm getting type mismatch errors in a Macro, and am trying to resolve it by checking to see if the cell contains an integer, but can't figure out how to do that.

Current line is
If Selection.Cells(i) > 0 Then l = l + 1

I'd like ti to be more like
If (Selection.Cells(i) > 0 AND Selection.Cells(i).type=Integer) Then l = l + 1

but that clearly doesn't work. What's the right language for this?

Configuration: Windows XP
Internet Explorer 6.0

Best answers for « Determining if a cell value is an integer » in :
[C language]Checking whether an integer is a prime number Show[C language]Checking whether an integer is a prime number Definition of a prime number Algorithm 1: dividers between 2 and N-1 will be tested Algorithm 2: Even dividers will not be tested, research is limited to odd dividers Algorithm 3:...
[Yahoo] Determine if my contacts are online Show[Yahoo] Determine if my contacts are online If you do not see if your contacts are online (if they still appear in gray, as "disconnected"), you may need to adjust proxy settings. In Yahoo Messenger, once connected, go to...
How to determine if a MSN account is disabled ShowHow to determine if a MSN account is disabled If you do not log in to your MSN Hotmail, MSN Messenger or Passport on the Windows Live ID site or via an instant messaging software (MSN, WLM, etc. ...) For more than 30 days will be...
Spreadsheets - Conditional expressions ShowWhat is a Conditional Structure? Conditional structures are instructions that allow to test if a condition is true or not. Conditional structures may be associated together. To successfully execute these tests using logical functions, spreadsheets...
Worksheet - Cells ShowThe Concept of a Cell A "cell" is the intersection between a line (horizontal) and a column (vertical) on a worksheet. Thus, the name of the line combined with the name of the column gives the cell's coordinates (the term address is sometimes also...

1

 WutUp WutUp, on Mar 4, 2009 9:15:49 pm GMT

Maybe you can try an information function with a data type function. Something like.......

If IsNumeric(Val(Selection.Cells(i))) Then
l = l + 1

Reply to WutUp WutUp