cypher1985
New Member
- Joined
- Jan 20, 2023
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Due to a few reasons regarding cell security and trying to consider user requests. I've been forced down a road to make a button that allows me to insert a user selected number of rows, below a user selected row number. See below;
This is tied to a button on the sheet and works exactly as I need. I just need to add one more condition. After the 2nd prompt, I only want users to be able to type a number higher than 27 for the row number, as that is where the user input data starts. If its lower than 27. Would be nice to have a prompt warning them to type a higher number next time, but this isn't essential. Then "End This Sub" if lower than 27, or carry on with the code if higher than 27. Problem is I'm not sure where to place the condition to do that or even the code required.
Hitting a wall with this and its taken a few days just to get the above working. So any help from the gurus would be greatly appreciated
Sub InsertRow() ' ' ButtonInsertRow ' Inserts a new row ' ' Keyboard Shortcut: Ctrl+Shift+I ' ActiveSheet.Unprotect Password:="123dreid" Dim iRow As Long Dim iCount As Long Dim i As Long iCount = InputBox(Prompt:="How many rows you want to add?") iRow = InputBox _ (Prompt:="After which row you want to add new rows? (Enter the row number below. Must be higher than 27)") For i = 1 To iCount Rows(iRow).EntireRow.Insert Next i ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowInsertingRows:=True, AllowDeletingRows:=True, Password:="123dreid" End Sub |
This is tied to a button on the sheet and works exactly as I need. I just need to add one more condition. After the 2nd prompt, I only want users to be able to type a number higher than 27 for the row number, as that is where the user input data starts. If its lower than 27. Would be nice to have a prompt warning them to type a higher number next time, but this isn't essential. Then "End This Sub" if lower than 27, or carry on with the code if higher than 27. Problem is I'm not sure where to place the condition to do that or even the code required.
Hitting a wall with this and its taken a few days just to get the above working. So any help from the gurus would be greatly appreciated