outlawspeeder
Board Regular
- Joined
- Jan 17, 2009
- Messages
- 223
- Office Version
-
- 2019
This is my first time doing a if inside a if. I think I am close. There is mostly a better way of doing it.
Help
Sub RemovetoTAB()
Dim Bu As Worksheet
Set Bu = Sheets("Buttons")
Dim Wo As Worksheet
Set Wo = Sheets("Working")
Dim PA As Worksheet
Set PA = Sheets("PACK")
Dim wsf As WorksheetFunction
Dim LR1 As Long, LR2 As Long, LR3 As Long, i As Long, ii As Long, MN As Long
Set wsf = Application.WorksheetFunction
On Error Resume Next
Sheets("Working").Select
LR1 = Wo.Range("B" & Rows.Count).End(xlUp).row
For i = LR1 To 1 Step -1
'Bu.Range("B10:B25") is the range I am comparing "P" &i too
If IsError(wsf.Match(Wo.Range("P" & i), Bu.Range("B10:B25"), 0)) = False Then
'If IsError means if matched, no error thus false...then runs
'This should set the value for MN from column "B" in the sheet
MN = "Offset(0, -14)"
LR2 = Wo.Range("B" & Rows.Count).End(xlUp).row
For ii = LR2 To 1 Step -1
' this should us MN set above and if false copies and paste to the three sheet PACK
If IsError(wsf.Match(PA.Range("B" & ii), MN)) = False Then
Rows(ii).EntireRow.copy
Sheets("PACK").Select
LR3 = Range("B" & Rows.Count).End(xlUp).row
Rows.Paste
End If
Next
End If
Next
End Sub
Help
Sub RemovetoTAB()
Dim Bu As Worksheet
Set Bu = Sheets("Buttons")
Dim Wo As Worksheet
Set Wo = Sheets("Working")
Dim PA As Worksheet
Set PA = Sheets("PACK")
Dim wsf As WorksheetFunction
Dim LR1 As Long, LR2 As Long, LR3 As Long, i As Long, ii As Long, MN As Long
Set wsf = Application.WorksheetFunction
On Error Resume Next
Sheets("Working").Select
LR1 = Wo.Range("B" & Rows.Count).End(xlUp).row
For i = LR1 To 1 Step -1
'Bu.Range("B10:B25") is the range I am comparing "P" &i too
If IsError(wsf.Match(Wo.Range("P" & i), Bu.Range("B10:B25"), 0)) = False Then
'If IsError means if matched, no error thus false...then runs
'This should set the value for MN from column "B" in the sheet
MN = "Offset(0, -14)"
LR2 = Wo.Range("B" & Rows.Count).End(xlUp).row
For ii = LR2 To 1 Step -1
' this should us MN set above and if false copies and paste to the three sheet PACK
If IsError(wsf.Match(PA.Range("B" & ii), MN)) = False Then
Rows(ii).EntireRow.copy
Sheets("PACK").Select
LR3 = Range("B" & Rows.Count).End(xlUp).row
Rows.Paste
End If
Next
End If
Next
End Sub