• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1436
  • 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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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