Life_is_Good
New Member
- Joined
- Apr 19, 2018
- Messages
- 5
Hello All,
Here's what i'm trying to do:
I have a userform which prompts the user to populate numbers when a drop-down value on column D is "Yes". And based on the entered number, current row will be replicated.
However, I am running into Type Mismatch error 13 after the row is replicated. I believe it's because of the If Target.Column = currentCol And Target.Row = currentRow And Target.Value = "Yes" Then UserForm1.Show piece.
Could someone please solve this problem? I am not too familiar with error handling. Thanks a bunch in advance!
Worksheet change
Duplicates the current row based on the entered numbers.
Here's what i'm trying to do:
I have a userform which prompts the user to populate numbers when a drop-down value on column D is "Yes". And based on the entered number, current row will be replicated.
However, I am running into Type Mismatch error 13 after the row is replicated. I believe it's because of the If Target.Column = currentCol And Target.Row = currentRow And Target.Value = "Yes" Then UserForm1.Show piece.
Could someone please solve this problem? I am not too familiar with error handling. Thanks a bunch in advance!
Worksheet change
Code:
Sub Worksheet_Change(ByVal Target As Range)
Dim currentCol As Variant
Dim currentRow As Variant
currentCol = 4
currentRow = ActiveCell.Row
If Target.Column = currentCol And Target.Row = currentRow And Target.Value = "Yes" Then UserForm1.Show
End Sub
Duplicates the current row based on the entered numbers.
Code:
Private Sub OK_Btn_Click()
Dim xRow As Long
Dim VInSertNum As Variant
xRow = ActiveCell.Row
Application.ScreenUpdating = False
If Not IsNumeric(TextBox1.Value) Then
MsgBox "only numbers allowed"
Cancel = True
End If
VInSertNum = CInt(TextBox1.Value)
If ((VInSertNum > 1) And IsNumeric(VInSertNum)) Then
Range(Cells(xRow, "B"), Cells(xRow, "BB")).Copy
Range(Cells(xRow + 1, "B"), Cells(xRow + VInSertNum - 1, "BB")).Select
Selection.Insert Shift:=xlDown
Cells(xRow, "C").Value = Cells(xRow, "C").Value & VInSertNum - 1
xRow = xRow + VInSertNum - 1
End If
xRow = xRow + 1
Application.ScreenUpdating = False
UserForm1.Hide
End Sub