Solved

Excel VBA - Specify a specific column range to copy

Posted on 2014-04-29
3
1,073 Views
Last Modified: 2014-04-29
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
Comment
Question by:GPSPOW
3 Comments
 
LVL 21

Expert Comment

by:Ejgil Hedegaard
ID: 40030862
Expect you start in column B

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

Open in new window

0
 
LVL 23

Accepted Solution

by:
Michael74 earned 500 total points
ID: 40030868
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
 

Author Closing Comment

by:GPSPOW
ID: 40031057
Thanks

Glen
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now