VoG - Help if you're around please :) VBA problem

  Newuser3443 13:00 16 Aug 07

Sorry to call upon you again, but I need help with a small amount of Excel VBA coding please.

I need to look at a cell on each row of a spreadsheet and then colour the row dependant upon the cell content.

If I use a for-next loop to increment the row, how do I change the active cell (or row) based upon the value of the for-next loop?



  VoG II 13:18 16 Aug 07

You don't need to select or activate a cell in order to work with it. The following loops through row A and colours the entire row if a 1 is found.

Sub test()
Dim LastRow As Long, i As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To LastRow
If Range("A" & i).Value = 1 Then Rows(i).EntireRow.Interior.ColorIndex = 5
Next i
End Sub

  Newuser3443 13:24 16 Aug 07

Cheers mate and thanks for the rapid reply :)

This thread is now locked and can not be replied to.

Surface Pro (2017) vs Surface Pro 4

20 groundbreaking 3D animation techniques

How to mine Bitcoin on Mac