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

  Newuser3443 13:00 16 Aug 2007
Locked

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?

TIA

Rob

  VoG II 13:18 16 Aug 2007

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 2007

Cheers mate and thanks for the rapid reply :)

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

Elsewhere on IDG sites

Xiaomi Mi Mix 2 review

See mcbess's iconic style animated for Mercedes-Benz

iPhone X news: Release date, price, new features & specs

Black Friday 2017 : date, sites participants & bonnes affaires