"be consistent" | |
PerlMonks |
Re: Win32::OLE and Excel: Iterating when certain row numbers are missingby davies (Prior) |
on Jun 21, 2021 at 13:22 UTC ( [id://11134108]=note: print w/replies, xml ) | Need Help?? |
A quick first impression: your approach is never going to work. In your ### Do some stuff block, you are inserting a row. This will create the same problem as deleting a row, something I have analysed in RFC Tutorial - Deleting Excel Rows, Columns and Sheets. Start at the end and work backwards and you will eliminate at least one of your problems. Almost immediate update: the rows are numbered sequentially in every implementation of Excel (and every other spreadsheet - dozens) I have seen. However, rows and columns may be hidden. If they are hidden, that is from the human eye, not VBA or Perl. Your code will go from row 1 to row 2 regardless of whether row 2 is visible to you. Update 2: some code. Update 3 changed the code to include a demonstration of testing whether a row is hidden.
Run this code and you will see three hidden rows. This is because row 2 (B) has been copied to row 3. After that, row 3 (a copy of B) has been copied to row 4. This is the loop error bug I mention in my post about deleting rows. To reveal the rows, select rows 1 to 5, the two visible rows and the three hidden ones. Doing this with the mouse can be awkward, but I always prefer the keyboard anyway. Alt-H (Home), O (Format), U (Hide & Unhide), O (Unhide Rows) will show the three copies of what was row 2. If you are using a version with the old menu tree, it's Alt-O, R, U. Regards, John Davies
In Section
Seekers of Perl Wisdom
|
|