LinesToInsert = InputBox("How many lines to insert? (50 lines maximum)?")Ī(Int(LinesToInsert)).Insert If, on the other hand, you really want to impose that limit, then this slightly longer (but still shorter and more efficient than your posted code) can be used instead. Note that I removed the 50-line maximum as I saw no reason for such a limit. Regards, case you are interested, your posted macro can be replaced with this much shorter (and more efficient) one.Ī(Int(InputBox("How many lines to insert?"))).Insert 'Following line Adds a single row at row 3 of the table However, it inserts rows within the table range and any data below the table moves down.Īs a matter of interest, if you activate the code recorder and select multiple rows of the table and Right Click -> Insert -> Table rows above then you will find that it has recorded multiple lines of code by adding only one row for each line of code.įor i = 1 To Rows("3:" & 2 + CYA_rows).Rows.Count Note that the code expands the table on the worksheet it does not insert rows across the entire worksheet. ![]() Try the code below to add rows to the table only without inserting rows across the entire worksheet. Is this what you want to do? or do you want to insert rows across the worksheet as per Rick's answer? ![]() ![]() If you only want to add rows to the table without actually inserting rows across the worksheet then you need to use a loop to add multiple single rows.
0 Comments
Leave a Reply. |