View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Open another workbook and then some.... from another Workbook

The cells i have inputing values from ARE NOT the same cell references in
both sheets.


I was assuming you would change the cell references.

Workbook1.Sheets("Sheet1").Range("Z48").Value =
Workbook2.Sheets("Sheet2").Range("J60").Value

Where Workbook1 and Workbook2 are object variables that are set to the
appropriate workbooks.

Or

Workbook2.Sheets("Sheet2").Range("J60").Copy
Workbook1.Sheets("Sheet1").Range("Z48")

Again Workbook1 and Workbook2 are object variables.

Or,

Set WB = Workbooks.Open("Filename")
Set Rng1 = WB.Sheets("Sheet2").Range("J60")
Set Rng2 = Thisworkbook.Sheets("Sheet1").Range("Z48")
Rng1.Copy Rng2

Maybe post some of the code you are using instead of just stating the
suggestions thus far are not working. If you are getting an error message -
what does it say? Since you are able to open the workbook and add sheets, I
assume you no longer need to run the macro in the second book.


"Corey" wrote:

Application.Run (wkbTest.Name & "!" & "Test2")

Thanks for the reply.
The baove code i get an error.
I have renamed the value of Test2 to the macor name in workbook2.

I can get the following:

Opens 2nd workbook
Creates a new worksheet
But i get NO values from the 1st workbook worksheet input intot he 2nd
workbook worksheet.

The cells i have inputing values from ARE NOT the same cell references in
both sheets.
So workbook worksheet1 "Z48" = workbook worksheet2 "J60"


???
Any ideas
Corey....
"JMB" wrote in message
...
Where FName is the path to the second workbook, the macro in the second
workbook is called Test2, and you want to copy cells A1:C1 from Sheet1 to
Sheet1!A1 of your second book, this should help you some:

Sub test()
Const FName = "I:\Excel\Book2.xls"
Dim wkbTest As Workbook

Set wkbTest = Workbooks.Open(FName)
Application.Run (wkbTest.Name & "!" & "Test2")

ThisWorkbook.Sheets("Sheet1").Range("A1:C1").Copy _
wkbTest.Sheets("Sheet1").Range("A1")

wkbTest.Close savechanges:=True

End Sub


"Corey" wrote:

Is this possible?
Workbook (a)
Workbook (b)
From Workbook (a):
I want to be able to click a button that:
1. Opens Workbook (b)
2. Runs a macro in that Workbook(creates a new worksheet)
3. Then input some of the cell values from the Workbook (a) sheet into
cells
in Workbook (b)


Can this be done, or is it beyond Excel programming ?

Corey....