I guess I understand the concept, but can't tranlate it into actual codes - or make it to work right.
I can copy the 1st recordset successfully, and find the last row, but when I copy the 2nd recordset, the previous load disappears from the spreadsheet. What's the right way to copy the 2nd recordset?
I tried with your example, then modified a bit (I use Cells, instead of Range during the 1st copy):
With SS1.ActiveSheet
For i = 0 To adoRsB.Fields.Count - 1
.Cells(1,i+1).Value = adoRsB.Fields(i).Name
Next
.Cells.copyFromRecordset adoRsB
LastRow = adoRsB.RecordCount + 1
adoRsB.Close
Set adoRsB = Nothing
Set adoRsC = CreateObject("ADODB.Recordset")
adoRsC.CursorLocation
adoRsC.CursorType = 1
adoRsC.LockType = 3
adoRsC.Open sGLSQL, adoCnn
msgbox lastrow
.Cells(LastRow+1,1).CopyFromRecordset adoRsC
adoRsC.Close
Set adoRsC = Nothing
.Range("A2").Select
End With
SS1.ActiveWindow.FreezePanes = True
With this above code, I see the 1st copy worked fine, then when 2nd copy 'erase' the 1st copy and only fills the A2 cell with 1st column name of the 2nd recordset.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.