# Need help on a if statment inside an if

#### outlawspeeder

##### Board Regular
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

### Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

#### Boller

##### Banned
It might help if you can describe what the macro is supposed to be doing.

Does the code you posted do what you want it to do?
If not, what is it not doing?

#### outlawspeeder

##### Board Regular
Set Bu = Sheets("Buttons")
Set Wo = Sheets("Working")
Set PA = Sheets("PACK")

On "Buttons" tab I have a field (B10:B25) that I can enter data. When the code runs it should look at the "Working" tab, column "P" from the bottom.

As it loops up column "P" and coulmn "P" and (B10:B25) match, the code needs to get the value of column "B" from that row.

Again with the new value set as "MN" it should start at the bottom of column "B" and loop upward until if finds a match. When found, it should copy that row to the 'PACK" tab. It should then go back to the first loop and cotinue up column "B' until it finds the next match to MN and copy that row to the PACK tab untill it gets to the top.

It should then go back and finish looping the "P" and (B10:B25) match. If anonther macth is found it repeats the 2nd loop.

The best way to discribe this is I know the value I need to look for in column "P" to find the value I need to move to the PACK tab.

Once I have this, I can do the same for the other four tabs in the same way.

I think I am close. Thanks for any help

Replies
2
Views
355
Replies
12
Views
565
Replies
1
Views
2K
Replies
8
Views
293
Replies
21
Views
2K

1,191,691
Messages
5,988,111
Members
440,126
Latest member
duque00

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Which adblocker are you using?

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back