Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel VBA - Specify a specific column range to copy

Posted on 2014-04-29
3
Medium Priority
?
1,380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 23

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:
Michael Fowler earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

636 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