INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Interior Colouring used cells in a Row

Interior Colouring used cells in a Row

(OP)
hi - I'm totally new to Excel VBA. I've need code to copy the tables in a set of worksheets into Sheets(1). All works perfectly.

But, I now want to fill the header row cells of each table using, say, colorindex = 37.

As I loop through Sheets(2) to the end, I run the following code fragment...

CODE

Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(3)
Sheets(1).Range("A65536").End(xlUp)(-29).Interior.ColorIndex = 37 

The first line works perfectly, copying each table below the previous one. My problem is how to do the coloring of the header rows of each table.

My 2nd line of code above work, BUT ONLY in column A. In each table, I need to color from A to Q.

Any help for this newbie is appreciated!
Vicky

RE: Interior Colouring used cells in a Row

Hi,

First a technical issue that could have an impact further down the road. 65536 is the number of rows in Excel version 2003 I believe. A better way of specifying the last row in a sheet is Cells.Rows.Count.

Now to your issues. "My problem is how to do the coloring of the header rows of each table."

Your code seems to indicate that you're stacking these tables one under another with two rows separating each. Am I correct?

Okay, here's a solution, but I have serious questions regarding the approach that you're using. 1) I wouldn't be using Selection.Copy, 2) I definitely wouldn't be stacking tables.

CODE

'
    With Sheets(1)
        Selection.Copy Destination:=.Cells(.Cells.Rows.Count, "A").End(xlUp).Offset(2)
        With .Cells(.Cells.Rows.Count, "A").End(xlUp).CurrentRegion
            Range(.Cells(1, "A"), .Cells(1, "A").End(xlToRight)).Interior.ColorIndex = 37
        End With
    End With 


Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Interior Colouring used cells in a Row

(OP)
thanks, Skip, for a quick response, and for the advice.
Vicky

RE: Interior Colouring used cells in a Row

Can you explain what you're attempting to accomplish with this stacking approach?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close