简体   繁体   English

读取Excel行,将行标记为已读

[英]Read Excel rows, mark rows read

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. 我需要使用VBA将Excel中的行读取到另一个应用程序中,但是如果该进程在中间终止,则需要知道读取了哪些行。

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. 谢谢大家。

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. 如果无法处理原始文档,请先将所有内容复制到新的工作表中,然后在处理过程中清除内容。

将整个范围读入数组(矩阵),并跟踪位置(索引),将位置值保存到文件或数据库中。

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. 这样,您不必将状态数据保存在电子表格中,也不必每次都保存它,这会大大降低VBA的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM