Adding Rows - Macro

GallowayJay

New Member
Joined
Apr 8, 2002
Messages
15
Hello!

I want to be able to automatically add rows to a particular sheet. My ultimate goal is to have an individual enter the number of rows they desire. Then the sheet would provide the amount of row space requested. I intend to protect the sheet from unauthorized adjustments, but in order to satisfy the row requirement, I need some macro (or function) in place. The Alt-Insert-Rows will not work in a protected sheet. Therefore, I need an alternative. Any ideas from the gurus of this board?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
To add rows to a protected worksheet you have to first unprotect the worksheet, like the following:

ActiveSheet.Unprotect
[a1].EntireRow.Insert
ActiveSheet.Protect

If you want the user to specify the number of row to add, try the following:

Dim NumOfRows As Long
NumOfRows = InputBox("Enter Number of Rows to Add")
ActiveSheet.Unprotect
For i = 1 To NumOfRows
[a1].EntireRow.Insert
Next
ActiveSheet.Protect
_________________
Hope this helps.
Kind regards, Al.
This message was edited by Al Chara on 2002-04-09 08:07
 
Upvote 0
Al,

Thanks alot for the help! It is working, but for one problem - I am looping continuously until the file crashes. I cannot determine exactly what the next step is at this point.

GallowayJay
 
Upvote 0
It shouldn't loop forever, it should just loop for the number of rows to add. What code are you using?
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,236
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top