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

  Newuser3443 13:00 16 Aug 07
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 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.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

The updated 'Corel Painter inside Photoshop' plugin ParticleShop offers new brushes

New MacBook Pro 2017 release date, UK price and tech specs: Kaby Lake MacBook Pro to launch in…