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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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,231
Messages
6,170,884
Members
452,364
Latest member
springate

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