Loop with two statements

elmnas

Board Regular
Joined
Feb 20, 2015
Messages
206
Hello everyone!

I have got a excel file that looks the one below:

erW3inj.png

Now I need a loop that check each cell in Column "H", if there is two cells in column "H" that matches each other (in this case Cell 1 and Cell 6).
Check in Column "i" if there is any data in any of these cells, remove the cell that have no data in Column "i".See result result below:

MnaTwLe.png


Could someone help me with this?

Thank you in advance
 
Last edited:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
try this

Code:
Sub ShreifOct25()

    Dim rng As Range
    Dim i As Long, x As Long
    i = Range("H" & Rows.Count).End(xlUp).Row
    Set rng = Range("h1", Range("h" & Rows.Count).End(xlUp))
    For x = i To 1 Step -1
        If Application.WorksheetFunction.CountIf(rng, Cells(x, 8)) > 1 And Cells(x, 9) = "" Then
            Cells(x, 8).Delete Shift:=xlUp
        End If
    Next x

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,223
Messages
6,123,727
Members
449,116
Latest member
Aaagu

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