michaeltsmith93
Board Regular
- Joined
- Sep 29, 2016
- Messages
- 83
I am using the following code to remove items from a list on the current sheet and put them on another sheet. These same items exist on neighboring sheets with different names. It works fine for FindRow and SearchRange, but it's not doing anything to FindRow2 and SearchRange2. I'm not getting an error though. Thoughts?
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 SearchRange2 As Range
Dim FindRow As Long
Dim FindRow2 As Long
Dim k4 As Worksheet
Dim k5 As Worksheet
Set k4 = Worksheets("Dropped-NotSelected")
Set k5 = Worksheets(MovePIs.RegionName.Value)
Set SearchRange = Range("D5:D2000")
Set SearchRange2 = k5.Range("D5:D2000")
ERow = k4.Range("D" & Rows.Count).End(xlUp).Row + 1
PINamesArray = Split(Me.PINames, "; ")
For x = LBound(PINamesArray) To UBound(PINamesArray)
FindRow = SearchRange.Find(What:=PINamesArray(x), LookIn:=xlValues).Row
If FindRow <> 0 Then
Rows(FindRow).Copy
k4.Cells(ERow, 1).PasteSpecial
Rows(FindRow).Delete Shift:=xlShiftUp
End If
FindRow2 = SearchRange2.Find(What:=PINamesArray(x), LookIn:=xlValues).Row
If FindRow2 <> 0 Then
Rows(FindRow2).Delete Shift:=xlShiftUp
End If
Next x
Unload Me
End Sub