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!

finding the first empy cell in a column

Status
Not open for further replies.

missprogrammer

Programmer
Nov 7, 2000
20
US
can you help me to get started on finding the first empy cell in a column
 
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.
 
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
 
Not a problem, I didn't explain it well.

(just to make sure I'm on thr right track)
You plan to exprt multiple recordsets to one Excel worksheet, and need to know upon which row to paste your next recordset, right?

"My thing is I wont know how may records exist in each recordset. "

If you use the recordcount function [RecordSetName].Recordcount, this will give you the number of records in a recordset.

What does you code look like for this function? So I know which direction to go with my directions.

Kyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top