title: Excel VBA Nested For Each loops using named ranges
body: <p>Has anyone found using nested For Each Loops given the named-ranges a hindrance?</p>
  
  <p>Here is a situation I am attempting to make it work, thinking that since named ranges can be helpful (for me) to know which belongs to what.</p>
  
  <p>The requirement of a made-up business has a Program name [named ListofPrograms] which is allocated a colour (has 9), each day [named ListofDates] (over 10 days) an random allocated number of Australian Cows [named ListofCows] (out of 5) are placed in the coloured Program for testing by student vets to demonstrate to their teachers of their academic research and clinical outcomes.</p>
  
  <p>Here the VBA code of how I could have done it. I used the Debug.Print for now as I am not sure how to populate Sheets("Outcome") successfully in this manner.</p>
  
  <pre><code> Option Explicit
  Sub CowsGenerator()
  Dim Programrng, Daterng, Cowsrng As Range
  
  With Sheets("Outcome")
      For Each Programrng In Range("ListofPrograms")
              For Each Daterng In Range("ListofDates")
                      For Each Cowsrng In Range("ListofCows")
                          Debug.Print Programrng.Value, Daterng.Value, Cowsrng.FormulaR1C1 = "=RANDBETWEEN(1,5)"
                      Next Cowsrng
              Next Daterng
      Next Programrng
  End With
  End Sub
  </code></pre>
  
  <p>Here is the snippet shown in the Immediate Window.</p>
  
  <pre><code> 6             1            False
   6             1            False
   6             2            False
   6             2            False
   6             2            False
   6             2            False
   6             2            False
   6             3            False
   6             3            False
  </code></pre>
  
  <p>I didn't think False is a good response from RANDBETWEEN and I note it continues from 6 and not from 1.</p>
  
  <p>Any suggestions how I may improve this thanks, Peter.</p>