G
Guest
OK, this should be simple.... I'm trying to combine the cotents of several ranges onto a new workbook. I can get the needed range, and I can add a new workbook, but everytime I try to add the data into the cell, I get an error that says "System or application defined error"
Here's the relevant code
Private Sub rangeData(StartCell As String, EndCell As String
Dim objRange As Rang
Dim I, N As Intege
' ************************************************************
' This sub steps through a range and pulls all the data from i
' ************************************************************
Set objRange = objWB.Worksheets(2).Range(StartCell, EndCell
For I = 0 To objRange.Rows.Coun
For N = 1 To
If Trim(objRange(I, N)) <> "" The
objNewBook.Worksheets(1).Range(Cells(lngLastRow, N)) = objRange(I, N) ' This line has the erro
End I
Nex
lngLastRow = lngLastRow +
Nex
Set objRange = Nothin
End Su
I know that objRange(I, N) has the value I want, but for some reason I can't add it into objNewBook. Here's the code that created the new book
Application.SheetsInNewWorkbook =
Set objNewBook = objXL.Workbooks.Ad
lngLastRow =
Application.SheetsInNewWorkbook =
objNewBook is defined with project level scope
Help!!
Here's the relevant code
Private Sub rangeData(StartCell As String, EndCell As String
Dim objRange As Rang
Dim I, N As Intege
' ************************************************************
' This sub steps through a range and pulls all the data from i
' ************************************************************
Set objRange = objWB.Worksheets(2).Range(StartCell, EndCell
For I = 0 To objRange.Rows.Coun
For N = 1 To
If Trim(objRange(I, N)) <> "" The
objNewBook.Worksheets(1).Range(Cells(lngLastRow, N)) = objRange(I, N) ' This line has the erro
End I
Nex
lngLastRow = lngLastRow +
Nex
Set objRange = Nothin
End Su
I know that objRange(I, N) has the value I want, but for some reason I can't add it into objNewBook. Here's the code that created the new book
Application.SheetsInNewWorkbook =
Set objNewBook = objXL.Workbooks.Ad
lngLastRow =
Application.SheetsInNewWorkbook =
objNewBook is defined with project level scope
Help!!