Multiple For Each

gazisere

New Member
Joined
Jun 21, 2019
Messages
4
Hello

I'm looking for some help on the below code. I basically want the cell K15:O16 to update the value from the range C6:C8 and K9:O10 to update from D6:D8 range.

I am able to get this working when only updating one cell after each print, but I cannot seem to get both cells updating. The below code sort of works, however it prints me 9 pages with every combination instead of just printing 3 and working down both ranges.

Thank you for any help in advance!

Code:
Sub LoopRange()


    Dim rCell As Range
    Dim rRng As Range
    Dim iCell As Range
    Dim iRng As Range


    Set rRng = Worksheets("MASTER").Range("C6:C8")
    Set iRng = Worksheets("MASTER").Range("D6:D8")


    For Each rCell In rRng.Rows
    For Each iCell In iRng.Rows
        Worksheets("cSheet").Range("K15:O16").Value = rCell.Value
        Worksheets("cSheet").Range("K9:O10").Value = iCell.Value
        Worksheets("cSheet").PrintOut
Next
        Next
    
        


End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I have managed to fix this by using a vLookup on the other cell to work along side the Macro.

Moderators can please close. Thank you. :cool:
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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