Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AccessIsFun - -call me stupid, but I dont understand. 1

Status
Not open for further replies.

missprogrammer

Programmer
Nov 7, 2000
20
US
sorry, should of been more detailed. I am pasting my results of several recordsets into excel using vba. My thing is I wont know how may records exist in each recordset. So I can I find the last used cell or fist empty cell.




AccessIsFun (Programmer) Nov 19, 2001
You could count the recordsets before you paste them. Then set your next starting point at RecordCount (of the first rescordset) + 2 (Excel starts at one, and if you're putting headers in, then you'll need to account for 2 spaces to make sure that you don't overlap).

Obviously adjusting for your next recordsets e.g. Starting point 3 = RecordCount1 + RecordCount2 + 1 et cetera

Dim RecCnt as Integer, rst as RecordSet
Set rst = CurrentdB.OpenRecordset ("[TableName]")
RecCnt = rst.RecordCount

Hope this helps

Kyle





 
Public lRealLastRow As Long
Public lRealLastColumn As Long


lRealLastRow = 0
lRealLastColumn = 0
Range("A1").Select
On Error Resume Next
lRealLastRow = Cells.Find("*", Range("A1"), xlFormulas, , xlByRows, xlPrevious).Row
lRealLastColumn = Cells.Find("*", Range("A1"), xlFormulas, , xlByColumns, xlPrevious).Column
Cells(lRealLastRow, lRealLastColumn).Select
 
Try.....
Row number of last cell used:

<Sheet object>.range(<column to check>).specialcells(xlcelltypelastcell).row

e.g.

thisworkbook.ActiveSheet.range(&quot;A:A&quot;).specialcells(xlcelltypelastcell).row

M :)
 
perhaps you can avoid the issue by joining the recordsets in Ms. Access by use of a UNION query.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Very good point Michael. If she joined them all before exporting, then when to append wouldn't be an issue at all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top