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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB & Excel

Status
Not open for further replies.

VBdevil

Programmer
Sep 19, 2002
75
IL
Hi,
I have an application written in Visual Basic 5.0, which writes data to an Excel file, one row at a time. My problem is, how can I find the number of the next available (empty) row so I know where I can enter new data?
If I could find the first cell in the next available row, that would help also.
Thanks
 
Find the empty rows first and store the column,row pointers in an array. ie... Array.col and array .row
Then populate the spreadsheet by cycling through the array.

Record type testarray
col as string
row as string
End type

Dim MyArray() as testarray

'In Procedure...

Dim I as Integer
Dim J as Integer
Dim TestNum as BooleanI = 1
TestNum = False
Do until TestNum
'Find first empty row
ReDim Preserve MyArray(I)
MyArray.col = CurCol
MyArray.Row = CurRow

I = I + 1
If EndOfSpreadsheet then TestNum = True
Loop


This is very simplified but you should get the idea then use the Array to populate the spreadsheet with your data.

Good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top