FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,368
- Office Version
- 365
- 2016
- Platform
- Windows
If have a double click procedure that will add some new rows. As you can see the .Resize is hard coded right now, but I would like to grab a number from the user as they input their desired number rows.
How do I pass the value from the Sub back to the double click?
How do I pass the value from the Sub back to the double click?
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Application.ScreenUpdating = False
If Target.Column = 1 Then
On Error Resume Next
Target.EntireRow.Copy
Range("A" & Target.Row).Offset(1, 0).Resize(12).Insert Shift:=xlDown
Range("A" & Target.Row).Offset(1, 0).Resize(12).Value = "Add"
End If
Application.ScreenUpdating = True
End Sub
VBA Code:
Public Sub MyInputBox()
Dim msg As String: msg = "Please enter a number in the box below for the number of records you would like to add"
Dim MyInput As String: MyInput = InputBox(msg, "Adding additional records", "Enter your input number here!")
If MyInput = "Enter your input number here!" Or MyInput = "" Then
Exit Sub
End If
End Sub