• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1610
  • Last Modified:

Excel VBA - Specify a specific column range to copy

Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select

The above vba code will paint the range I need to copy.  However, I only want columns B:G instead of the "End(xlToRight).

How do I modify the above to paint all the row with data and columns B:G?

Thanks

Glen
0
GPSPOW
Asked:
GPSPOW
1 Solution
 
Ejgil HedegaardCommented:
Expect you start in column B

Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.Offset(0, 5)).Select

Open in new window

0
 
Michael FowlerSolutions ConsultantCommented:
Try this
dim r as long
r = Range(Selection, Selection.End(xlDown)).row
Range("B" & Selection.row, "G" & r).Select

Open in new window


Note: It is always better to avoid using select as this will slow down the VBA considerably

Michael
0
 
GPSPOWAuthor Commented:
Thanks

Glen
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now