View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Changing the background color of a cell

Steve

You can set that as
Set rng1 = Worksheets("Cappuchino Data").Range("G:G")
Set rng2 = Worksheets("Subs Safety Net").Range("C:C")

OR using named range

Set rng1 = Worksheets("Cappuchino Data").Range("namedrange1")
Set rng2 = Worksheets("Subs Safety Net").Range("namedrange2")



If this post helps click Yes
---------------
Jacob Skaria


"Steve" wrote:

Hi

Many thanks for your response and help

Yes it does seem to have worked (i just need to confirm), however, my only
question is, I don't always know the length of each of the lists so I can't
put the range in. In this instance, I changed the values but it would be nice
to have a generic routine that will work for any lists.

I havea routine that returns the number of lines in a list so using that
would be good.

Many Thanks

Steve

"Steve" wrote:

Hi

I'm comparing two lists and if a contract number equals that on another list
I want to highlight the line in the original list. I have looked for ages on
the web but everywhere that uses the range command seems to assume you know
the row but I'm trying to use two variables as below.

If Trim(Worksheets("Cappuchino Data").Cells(iCappuchinoRow,
7).Value) = Trim(Worksheets("Subs Safety Net").Cells(iSubsSafetyRow,
3).Value) Then

Worksheets("Cappuchino Data").Range(Cells(iCappuchinoRow, 1),
Cells(iCappuchinoRow, 31)).Interior.Color = 1
GoTo NextCappLine

End If

However, this just throws up an error.

Can you please help?

Many Thanks

Steve