referring to a range outside an activeworkbook

youngda

Board Regular
Joined
Jun 13, 2006
Messages
81
This should just be a simple problem, I've been taking the advice of several helpful people on this board but this code is still bothering me. Its a simple problem:

Dim wborignal As Workbook
Dim wbOut As Workbook

Set wboriginal = ActiveWorkbook

Workbooks.Add
Set wbOut = ActiveWorkbook

wboriginal.Range("A2", Cells(CurrentOutput, 21)).Copy

With wbOut.ActiveSheet
.Cells(2, 1).PasteSpecial Paste:=xlPasteValues
.Range("a1").Value = 8007706
End WIth

THe line that tries to copy is what is not working. Everything else should work fine. What am I missing here?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
Quote

wboriginal.Range("A2", Cells(CurrentOutput, 21)).Copy

With wbOut.ActiveSheet
.Cells(2, 1).PasteSpecial Paste:=xlPasteValues
.Range("a1").Value = 8007706
End With
Unquote

Try this . it is possible you may succeed.

Wboriginal.activate
Range(range(“a2”),cells(currentoutput,21)).copy
Wbout.activate
Cells(2,1).pastespecial ………..
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
try

Dim wborignal As Workbook
Dim wbOut As Workbook

Set wboriginal = ActiveWorkbook

Set wbOut = Workbooks.Add

With wboriginal.ActiveSheet
.Range("A2", .Cells(CurrentOutput, 21)).Copy
End With

With wbOut.Sheets(1)
.Cells(2, 1).PasteSpecial Paste:=xlPasteValues
.Range("a1").Value = 8007706
End WIth
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows
youngda

Could you please stick to the original thread?

And also answer the question(s) asked in it?
 

Forum statistics

Threads
1,136,275
Messages
5,674,786
Members
419,524
Latest member
helensesc

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
Top