set up a macro in Excel to color cells when clicked

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would liketo create a spreasheet that will highlight the value in the first
column if there ia value in another column of the same row.
 
Sub Test
Dim iLastRow As Long
Dim i As Long

For i = 1 To UsedRange.Rows.Count
If Application.Count(Range("B" & i).Resize(,255)) > 0 Then
Cells(i,"A").Interior.Colorindex = 36
End If
Next i

End Sub
 
Could you give me a little more instructions with this Macro? Where am I
suppose to insert the lines to be used?

Thanks.
rebecca
 
Hi Rebecca,

Thinking about this, I now think it is better to use conditional formatting.

Select A1 through to An for all relevant rows

Menu Format>Conditional Formatting
Change Condition 1 to Formula Is
Add this formula =COUNTA(B1:IV1)>0
Click Format
Select the pattern tab
Choose an acceptable highlight colour
OK
OK

Should now work okay
 

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