title: VBA: Seeking help in code modification
body: <p>I am a VBA learner, and I am trying to build a VBA project for improving my knowledge. There is a slight confusion on how to populate different data(based on some condition) to a set of same field.</p>
  
  <p>I have 3 scenarios:</p>
  
  <p>Scenario 1: User select all the checkbox<br>
  Scenario 2: User select only 1 or 2 checkbox<br>
  Scenario 3: User not selecting anything  </p>
  
  <p>My code will work perfectly with scenarios 1 and 3 but not able to figure it out how to accomplish scenario 2.</p>
  
  <p>My expectation is to populate the values from Cell B3 to B17 based on what user selects when Userform pop up to him. If he selects only 1 field corresponding values should be populated from B3 – B8, if he selects 2 checkboxes then the 1st corresponding value will be populated from B3 – B8 and 2nd set from B9 – B14 and so on.  Please find the images below for better understanding </p>
  
  <p><strong>Userform</strong><br>
  <a href="https://i.stack.imgur.com/ogSc5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ogSc5.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Example of Scenario 1</strong><br>
  <a href="https://i.stack.imgur.com/SuO3n.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SuO3n.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Example of Scenario 3</strong><br>
  <a href="https://i.stack.imgur.com/IuK9i.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IuK9i.jpg" alt="enter image description here"></a></p>
  
  <p><strong>VBA Code</strong>  </p>
  
  <pre><code>Dim i As Integer
  i = 3
  Do While i &lt; 8 And UF1_Location_and_Role.CheckBox6.Value = True
      Cells(i, 2).Value = "India"
      i = i + 1
  Loop
  
  Do While i &lt; 13 And UF1_Location_and_Role.CheckBox7.Value = True
      Cells(i, 2).Value = "Germany"
      i = i + 1
  Loop
  
  Do While i &lt; 18 And UF1_Location_and_Role.CheckBox7.Value = True
      Cells(i, 2).Value = "Hongkong"
      i = i + 1
  Loop
  </code></pre>