Solved

How to Copy range in another workbook to present position in active workbook

Posted on 2013-01-03
4
293 Views
Last Modified: 2013-01-03
I have a workbook, Book1,  with a range of cells which I want to copy to the active workbook, Book2, in the present position.
Both workbooks are open, but Book2 is active and the active cell is already determined by VBA.
I prefer that the focus does not shift to the source workbook, but only refer to the range in that workbook.
I want to use VBA. Can you help with the code please.
0
Comment
Question by:Fritz Paul
  • 2
4 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 38739284
What do you mean by 'present position' ??
gowflow
0
 
LVL 29

Expert Comment

by:gowflow
ID: 38739292
if WS1 is workbook1 Sheet1 and WS2 is workbook2 Sheet1 or any sheet then to copy say range A1:B6 in Book1 then

WS1.range("A1:B6").copy WS2.activecell

will copy the Range A!:B6 fm Book1 to the Activecell in Book2

gowflow
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 38739294
You could do something like this:

Dim rngSource As Range
Set rngSource = Workbooks("SourceBook").Worksheets("Sheet1").Range("a1:a10")
rngSource.Copy ActiveCell

Open in new window

0
 

Author Closing Comment

by:Fritz Paul
ID: 38739791
Thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

770 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