I have this excel sheet where : (file attached- Values in row 11 are compared with a value in Cells(7,6)
- The code has to identify a value in row 11 by
- Cells(rw5, 11) - Cells(7, 6) <= 20 And Cells(rw5, 11) - Cells(7, 6) > 0
- After it identifies its color index and its characters have to be changed
My problem:- Code works fine but it also highlights any cell that was first selected.
- Eg. when you open up this sheet and click on a cell anywhere (say Rang A1) and then run this program. The code in addition to what I want it to do, also highlights Range A1
- I guess it has to do with Activcell.select thingy
Code Used
Sub max()
Dim rw5 As Long
For rw5 = 17 To 46
If Cells(rw5, 11) - Cells(7, 6) <= 20 And Cells(rw5, 11) - Cells(7, 6) > 0 Then Cells(rw5, 11).Select
ActiveCell.Interior.ColorIndex = 6
ActiveCell.Font.Color = vbBlack
ActiveCell.Font.Bold = True
'End If
Next rw5
End Sub
Another concern..
Doesn’t allow me to use END IF… is there a reason why it doesn’t allow me to use END IF in spite of having IF
Bookmarks