Compare

Closed
PJW - 17 Mar 2010 à 06:52
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 17 Mar 2010 à 09:17
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 28 January 2010 Status Contributor Last seen 5 May 2022 766
17 Mar 2010 à 09:17
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