View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default How do I call up a line of code that references a cell/range in the active workbook workbook where I am running my macro from?

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
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

?