PC Review


Reply
Thread Tools Rate Thread

How do I call up a line of code that references a cell/range in theactive workbook workbook where I am running my macro from?

 
 
Lav
Guest
Posts: n/a
 
      11th Nov 2008
E.g. The macro is in workbook1.xls

I wish to copy cell B2

So Activeworkbook.Select

Dim Workbook1

Set Workbook1 = Workbooks.Add (or is it Open?)("C:Workbook1.xls")

Workbook1.Activate

Range("B2").Copy

?
 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      11th Nov 2008
The ActiveWorkbook object references the workbook that is presently
active in Excel. It may or may not be the workbook that contains the
currently executing code. The ThisWorkbook object references the
workbook that contains the executing code, regardless of what workbook
happens to be active in Excel.


> Workbooks.Add (or is it Open?)("C:Workbook1.xls")


The Add method is used to create a new workbook. The Open method is
used to open an existing workbook.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Tue, 11 Nov 2008 06:49:47 -0800 (PST), Lav
<(E-Mail Removed)> wrote:

>E.g. The macro is in workbook1.xls
>
>I wish to copy cell B2
>
>So Activeworkbook.Select
>
>Dim Workbook1
>
>Set Workbook1 = Workbooks.Add (or is it Open?)("C:Workbook1.xls")
>
>Workbook1.Activate
>
>Range("B2").Copy
>
>?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Store cell & workbook references, to retrieve later in Macro =?Utf-8?B?Q2hyaXMgVC1N?= Microsoft Excel Programming 3 13th Jun 2007 11:01 PM
Re: need macro to call a workbook w/o the actual name of the workbook Jon Peltier Microsoft Excel Programming 0 18th Dec 2006 10:01 PM
Copy Range to a New WorkBook + Name Sheet a cell Value + Name WorkBook another Celll Value Corey Microsoft Excel Programming 2 2nd Nov 2006 05:01 AM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Microsoft Excel Programming 9 25th Jul 2005 12:44 PM
Need a macro to copy a range in one workbook and paste into another workbook Paul Microsoft Excel Programming 8 1st Jul 2004 07:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:16 AM.