ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Not Completely Working (https://www.excelbanter.com/excel-programming/395685-re-macro-not-completely-working.html)

Jim Thomlinson

Macro Not Completely Working
 
Sub ColorCellLessThan1000orBlank()
Dim rngToSearch As Range
Dim rng As Range

Set rngToSearch = Range(Range("K1"), _
Cells(Rows.Count, "K").End(xlUp))

For Each rng In rngToSearch
If rng.Value < 1000 Then rng.Interior.ColorIndex = 7
Next rng
End Sub
--
HTH...

Jim Thomlinson


"Beep Beep" wrote:

As you can see this macro should find a number less than 1000 and then color
it.
It finds the number, however will not color it, and also there may be
multiple cells with less than 1000. Could you help me in getting this macro
to find one and color it and then continue on to the end. Joel has helped
but for some reason his solution does not work.

Sub ColorCellLessThan1000orBlank()

Range("K1").Select

Do Until ActiveCell < 1000
If ActiveCell < 1000 Then
With Selection.Interior
.PatternColorIndex = 7
.Pattern = x1solid
End With

End If
ActiveCell.Offset(1, 0).Select


Loop
End Sub



All times are GMT +1. The time now is 09:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com