views:

146

answers:

3

I need to use VBA to read rows out of Excel into another application, but if the process dies in the middle, I need to know which rows were read.

Is the best way to put something in a column, per row, that says that row was done? Then save it after every row is read?

Doesn't seem like a great way.

Any help would be great. Thanks everybody.

A: 

Read the entire range into an array (matrix), and keep track of the position (index), saving the position value to a file or database.

Lance Roberts
A: 

Not knowing what application you are writing to, it might be best to check that the data does not exist in the destination application for each and every write. Make an index or some other autonumber (to use a database term) in your destination app. This way you don't have to save the state data in your spreadsheet and save it every time, which will slow down your VBA big time.

Scott Lundberg
+1  A: 

I usually write the row to another sheet, then delete it from the original. That way your original is always what's unwritten, but you still have the written data. If you can't muck with the original, start by copying everything to a new sheet, then clearing contents as you process.

Dick Kusleika