IF statement with multiple conditions looking in a few ranges.

PumpC12

New Member
Joined
Apr 23, 2020
Messages
1
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi all,
I am trying to pull the date from the top in row 17 to another sheet if there is a value in row 21 and if Q21 = OCP
1587667893298.png


In addition I want the date to go to one of the following cells and fill from top down. For example in the above picture it would only pull the date from R17, T17, V17 and put it in A6,A8,A10.
1587668097666.png



Here is the code I have come up with so far. This returns the date of 4/18 all the way down in the image above.
Any help would be greatly appreciated.
VBA Code:
Sub OCPumping_If()
Dim cell As Range
Dim Cells As Range
Dim Code As Range
Dim Block As Range
    
    For Each cell In Range("'Wk 1'!R21:AA21")
        For Each Code In Range("'Wk 1'!Q21")
            For Each Cells In Range("'Wk 1'!R17:AA17")
                For Each Block In Range("'OCP Wk 1'!A6:A20")
                
                        
                    If cell.Value <> "" And Code.Value = "OCP" Then
    
                    Block.Value = Cells.Value
        
                     End If
                Next
            Next
        Next
    Next
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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?

Disable AdBlock

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
Back
Top