Looping ranges at the sametime

christian2016

Board Regular
Joined
Oct 6, 2016
Messages
123
Hi Guys,

I have the below code.

How do i loop through both loops at the same time?


Example
B2 & C2
B3 & C3
B4 & C4

At the moment it will loop through one at a time.

Any help is greatly appreciated.

Thanks



Code:
Set xRg1 = Sheets("Sheet1").Range("B2:B6")
Set xRg = Sheets("Sheet1").Range("C2:C5")


   For Each xCell1 In xRg1
       For Each xCell In xRg
           If xCell.Value Like "Review Pending" And xCell1.Value Like "*@*" And xEmailAddr1 = "" Then
        xEmailAddr1 = xCell1.Value
        
          Else
            xEmailAddr1 = xEmailAddr1 & ";" & xCell1.Value
             End If
             
             Next xCell
             Next xCell1
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
xcell1 is xcell.offset(0,1) so if you loop xcell only then in your If statement replace xcell1 with xcell.offset(0,1)
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

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