|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Compare a cell to an input
I am trying to analyze each cell in a range (1 to 108) which is numbers in this format (200312 for yearmonth). If the cell number is less than 200312, I want it to be red. Each time I do the code it makes every cell in the range red regardless of number or if the cell is empty. Any suggestions?
Thanks. Jake |
|
#2
|
||||
|
||||
|
Post your code for the text comparison and changing the cell forecolor - if it's in a sub, just post the whole sub- let us see what you are doing
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
|||
|
|||
|
Here's what I have so far:
Sub Scan() Range("b1").Select For RowIndex = 1 To 5 Worksheets("Sheet1").Cells(RowIndex, 1).Select If Worksheets("Sheet1").Cells(RowIndex, 1).Select <= Range("b1") Then With Selection.Interior .ColorIndex = 3 .Pattern = xlSolid End With Else End If Next RowIndex End Sub What I would eventually like to have is a prompt requested yearmonth (200401 for instance), then comparing that to existing cells and turning those less than 200412 to red. The first one greater than 200412 would stop the macro. Thanks Fisherman for the assist. |
|
#4
|
||||
|
||||
|
I thought you were wanting to change the color of the font?
|
|
#5
|
|||
|
|||
|
May I wasn't clear
I would like the code to select "A1", compare it to an input I provide (such as 200412) and if "A1" is less than 200412, the cell turns to red (actually the entire row). Once that is done, it cycles to cell "A2" and compares it to my input 200412 and does the same. Now, in cell "A3" the value would be (let's say) 200501, which then I would like the code to stop. Any suggestions. Wasn't an email. It was one from the website saying you replied. Thanks. Dave |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Compare a cell to an input |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|