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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
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,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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