View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mark Lincoln Mark Lincoln is offline
external usenet poster
 
Posts: 227
Default Why is inserting rows throwing off my hidden rows

Could this have to do with the fact that
I'm copy the data and doing and insert
instead of inserting the rows and then
copying and pasting the data?


Yes. Inserting an *entire row* will automatically shift all lower rows
down while maintaining the hidden attribute of hidden rows. What
you're doing is inserting *cells* which displace lower cells down to
the next row when you use Shift:=xlDown. If a cell is displaced from a
hidden row to one that is not hidden, then any data contained in the
cell will become visible.

You need to insert a row rather than cells if at all possible (thereby
maintaining the hidden status of the hidden rows below) then copy the
needed cells and paste them into the newly-created row.

If you can determine which row number needs to have the insert
performed, put that in an integer variable (I'll call it TheRow) and
use this to insert your new row:

Worksheets("Inline").Rows(TheRow).Insert

Use the same variable to tell Excel where to paste your data. (I'd be
more specific, but I have no access to Excel right now and can't test
anything. I'll try adding more later if you still need it.)