michaeltsmith93
Board Regular
- Joined
- Sep 29, 2016
- Messages
- 83
In the below code, I'm getting a subscript error on the line in red. Any ideas why this would be?
Code:
Private Sub OK_Click()
Dim x As Long, ERow As Long
Dim PINamesArray As Variant
Dim size As Long
Dim SearchRange As Range
Dim FindRow As Long
Dim k1 As Worksheet
Dim k2 As Worksheet
Set k1 = Worksheets("NA")
Set k2 = Worksheets("Dropped-NotSelected")
Set SearchRange = k1.Range("D5:D2000")
ERow = k2.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues, After:=k2.Range("A4")).Row + 1
PINamesArray = Split(Me.PINames, "; ")
size = UBound(PINamesArray) - LBound(PINamesArray) + 1
For x = 1 To size
[COLOR=#ff0000] FindRow = SearchRange.Find(What:=PINamesArray(x)).Row[/COLOR]
If FindRow <> 0 Then
Rows(FindRow).Copy
k2.Cells(ERow, 1).PasteAll
Rows(FindRow).Delete Shift:=xlShiftUp
End If
Next x
Unload Me
End Sub