|
-
Jul 29th, 2004, 03:04 PM
#1
Thread Starter
Hyperactive Member
How to determine the number of Rows/Columns in Excel File [VB6]
Given an excel file with X number of rows each having Y columns.
I need a mechanism that will allow me select each Cell.
For example:
For ( j = 0; j < x ; j++)
For (k = 0; k < y; k++)
‘Do whatever needs to be done.
This will then go over each row and each column in each row.
Given that I am importing data I do know beforehand how many columns (Y) should be there, I just want to ensure there is actually the right amount and therefore I need a way to determine (Y) from the file itself and compare it with the # I am expecting.
For the rows it is a little different, I need to go down and loop through all rows in the file, how do I tell it when to stop?
Is there a totally different/better way to do this?
Something built into the Excel object maybe? (Excel.endrow or something?)
Code so far:
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open(c:\test.xls, True)
Thanks,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|