Selection.Copy used in a variable.
Activating the worksheet seemed to be one key, your bit of code also revealed
another key.
This is what I ended up with that works.
'======
lRow = Range("A1").End(xlDown).Address
Sheets(1).Range("A1:" & lRow).Copy
'need to get new workbook name as variable 01.24.08
With Workbooks("TEMPLATE.xlsx")
.Worksheets.Add After:=.Worksheets(.Worksheets.Count)
Workbooks("TEMPLATE.xlsx").Activate 'activate workbook
ActiveSheet.Paste 'paste data from workbook "ListA"
End With
ActiveWindow.SelectedSheets.Visible = False
Workbooks("ListA.xlsx").Close
'======
Thanks for your help!
--
Regards
VBA.Noob.Confused
XP Pro
Office 2007
"Mike H" wrote:
Rick,
Maybe
Sub jj()
lRow = Range("A1").End(xlDown).Address
'MsgBox lRow 'for testing
vData = Range("A1:" & lRow).Copy
With ActiveWorkbook
.Worksheets.Add After:=.Worksheets(.Worksheets.Count)
ActiveSheet.Paste 'Object required?
End With
End Sub
Mike
"Rick S." wrote:
How do I pass the variable "vData"?
'======
lRow = Range("A1").End(xlDown).Address
'MsgBox lRow 'for testing
vData = Range("A1:" & lRow).Copy
With Workbooks("TEMPLATE.xlsx")
.Worksheets.Add After:=.Worksheets(.Worksheets.Count)
vData.Paste 'Object required?
End With
'======
--
Regards
VBA.Noob.Confused
XP Pro
Office 2007
|