×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

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.

Students Click Here

I'm very near a solution for form

I'm very near a solution for form

I'm very near a solution for form

(OP)

I'm very near a solution for formatting a range of cells in a worksheet created from Access

This colours alternate rows but does the entire rows, not just the parts in the specified range.

CODE -->

Dim LR As Long, i As Long
    'Find the last filled row in column A
    LR = Range("A" & Rows.Count).End(xlUp).Row
    
    'Loop through the filled rows in steps of 2
    For i = 2 To LR Step 2
        Rows(i).EntireRow.Interior.ColorIndex = 15
    Next i 

How do I limit to the columns in the range?

RE: I'm very near a solution for form

CODE

For i = 2 To LR Step 2
    Range("A" & i & ":G" & i).Interior.Color = 15
Next i 

This question would be better to ask in forum707: VBA Visual Basic for Applications (Microsoft) wiggle

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

RE: I'm very near a solution for form

(OP)

Thanks for this, did the job perfectly. It needed Interior.ColorIndex not Color, otherwise it filled alternate rows with black.
I'd used the Microsoft Office forum and didn't have the one you suggested on the 'My Forums' list, but do now.

RE: I'm very near a solution for form

Macro recorder in Excel is your friend. smile
Just Start recording, do your step(s) 'by-hand' of what you want to happen, and stop recording.
Alt-F11 will show you the code created. It is a very good starting point of coding in Excel's VBA

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

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! Already a Member? Login


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