Impossible Macro?
Well, I **just know** I tested the code before I posted it and I **know** it
worked AT THAT TIME... but now, I can't get the code to work correctly at
all. I have no idea what I did in my original tests to make it work, but
whatever I did then, I can't seem to repeat now. Okay, that's it... I'm off
trying to use the Selection for Inserts and Deletes from now on.<g Thanks
for watching my back on this.
--
Rick (MVP - Excel)
"Dave Peterson" wrote in message
...
I put data in A1:H20.
I selected rows 1:20 and stepped through the macro using 3 at the howmany
prompt.
After the first loop, I had empty cells in rows 2:4.
After the second loop, I had empty cells in rows 2:7.
then 2:10, ...
I'd also be careful with the selection.
If I started with A1:B3 selected, then the first loop put empty cells in:
A2:B4,
shifting the cells to the right.
After the second loop, I ended up with empty cells in: A2:b5 and C3:D4
and data
pushed further to the right.
Rick Rothstein wrote:
Actually, the code I posted works fine as is (I tested it<g).
--
Rick (MVP - Excel)
"Dave Peterson" wrote in message
...
I'd start from the bottom up <vbg.
Rick Rothstein wrote:
Does this do what you want...
Sub InsertRows()
Dim R As Range, HowMany As Long
HowMany = InputBox("How many rows should be inserted?")
For Each R In Selection.Rows
R.Offset(1).Resize(HowMany).Insert
Next
End Sub
--
Rick (MVP - Excel)
"JohnHero" wrote in message
...
I'd like to be able to have a macro that wouod work like this:
1) I highlight the rows
2) When I run the macro, it will ask me how many rows I'd like to
insert.
3) It would then insert x number of rows after each highlighted
cell.
Anybody able to help with this one?
--
Dave Peterson
--
Dave Peterson
|