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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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 ………..
 
Upvote 0
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
 
Upvote 0
youngda

Could you please stick to the original thread?

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

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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