×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-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!
  • Students Click Here

*Eng-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

Jobs

Excel Row Select in VBA

Excel Row Select in VBA

Excel Row Select in VBA

(OP)
This works by hand and is the same as the macro recorder but it doesn't work when I try to use it.

    Range("EG3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select

The rows are filtered and the first group of rows is blank which is what prompted the double range select; it selects just the blanks including the first non-blank cell it comes to.  I can hard code a fixed range but I'd prefer something more elegant which is where you guys come in.

RE: Excel Row Select in VBA

Funny behavior, that's for sure. A quick solution is to work it backwards:

CODE

    Range("EG3").Select
    Selection.End(xlDown).Select
    Selection.End(xlDown).Select
    Range(Selection, Range("EG3")).Select

Cheers,
Joerd

Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

RE: Excel Row Select in VBA

(OP)
Thanks.

I have another ?   When the macro closes a file I get a "Do you want to keep the clipboard stuff" decision window. How do I get the code to answer that?  I don't want to pick up the mouse to click no.

RE: Excel Row Select in VBA

Try
Application.CutCopyMode = False
at the end of the macro. This is a good habit anyway.

Cheers,
Joerd

Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

RE: Excel Row Select in VBA

(OP)
It didn't work at the end so I put it just before each close workbook line and it worked.

Many thanks,

Roger

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 Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

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


Resources