Compare

Closed
PJW - Mar 17, 2010 at 06:52 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Mar 17, 2010 at 09:17 AM
Hello,

I am trying to compare the value of a cell. To see if it is greater than one value and less than another. If true then add 1 to a variable. Please see below

Set ConstantCells = Selection.SpecialCells(xlCellTypeConstants)
For Each Cell In ConstantCells
If Cell.Value > 8.89 < 9.3 Then
Total1 = Total1 + 1
End If

The greater than/ less than (> 8.89 < 9.3 ) area doesn't work. Can anyone give me an alternative please.

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Mar 17, 2010 at 09:17 AM
Your if clause is not correct

If Cell.Value > 8.89 < 9.3 Then

this should be

If Cell.Value > 8.89 and cell.value < 9.3 Then
0