define workbook, sheet, and range so I dont have to copy activate and paste

maxx_daddy

Board Regular
Joined
Dec 3, 2010
Messages
74
Hi all.

here is what I have.
I am guessing that not specifically calling out the sheet where the ranges are is my issue here.
I am trying to copy a range in workbook "A" and paste it in workbook "BUTTON" without activating it.

Code:
Windows("BUTTON.xlsm").Range("joey") = Windows("a.xls").Range("joe").Value

here is the full code
Code:
Sub test2()Windows("BUTTON").Activate
Dim joey As Range
Set joey = Range("A30")


Windows("a.xls").Activate
With Worksheets("Page1")
Dim joe As Range
Set joe = Range("BD6")
End With


Windows("BUTTON.xlsm").Activate




Windows("BUTTON.xlsm").Range("joey") = Windows("a.xls").Range("joe").Value








End Sub

thanks, as always for your help.

Joe
 
Last edited:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi all.

here is what I have.
I am guessing that not specifically calling out the sheet where the ranges are is my issue here.
I am trying to copy a range in workbook "A" and paste it in workbook "BUTTON" without activating it.

Code:
Windows("BUTTON.xlsm").Range("joey") = Windows("a.xls").Range("joe").Value

here is the full code
Code:
Sub test2()Windows("BUTTON").Activate
Dim joey As Range
Set joey = Range("A30")


Windows("a.xls").Activate
With Worksheets("Page1")
Dim joe As Range
Set joe = Range("BD6")
End With


Windows("BUTTON.xlsm").Activate




Windows("BUTTON.xlsm").Range("joey") = Windows("a.xls").Range("joe").Value








End Sub

thanks, as always for your help.

Joe

If you are going to use the Windows method you have to Acivate before before doing something. One was activated but the other was not. If you use Workbooks() then you need to use the Sheet() and Range(), but you do not have to activate either the source or destination.
 
Upvote 0

Forum statistics

Threads
1,226,737
Messages
6,192,737
Members
453,753
Latest member
SORD

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top