Change the properties of a non selected cell?

  • Thread starter Thread starter Winshent
  • Start date Start date
W

Winshent

i have some code which validates a row.. and compares two columns in
the row. The code is triggered from Worksheet_SelectionChange(ByVal
Target As Range) within the worksheet.

i want to be able to set the colours of the cells if they do not pass
validation.. how can i do this with selecting the actual cell?

Thanks

Vincent
 
just refer to the cells

target.offset(0,1).Interior.ColorIndex = 5

or

cells(Target.row,"F").Interior.ColorIndex = 5

as examples.
 
Vincent,

Simply use the range object:

If YourCondition = Condition Then
Range("H1").Interior.ColorIndex = 3
Else
Range("H1").Interior.ColorIndex = xlNone
End If

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top