Loops and rows

kmiszcz

New Member
Joined
May 31, 2016
Messages
3
How to loop through table rows and then the columns?
I am new to VBA and what I am trying to do is to pull information into datasheet from user form, that enters 7 rows not 7 columns. Currently the code
Code:
'copy the data to the database
With ws
  .Cells(lRow, 2).Value = Me.cboEmployID.Value
  .Cells(lRow, 1).Value = Me.cboEmployID.List(lPart, 1)
  .Cells(lRow, 5).Value = Me.cboLocSun.Value
  .Cells(lRow, 7).Value = Me.cboLocMon.Value
  .Cells(lRow, 9).Value = Me.cboLocTue.Value
  .Cells(lRow, 11).Value = Me.cboLocWen.Value
  .Cells(lRow, 13).Value = Me.cboLocThu.Value
  .Cells(lRow, 15).Value = Me.cboLocFri.Value
  .Cells(lRow, 17).Value = Me.cboLocSat.Value
  .Cells(lRow, 4).Value = Me.DTPickerSun.Value
  .Cells(lRow, 6).Value = Me.DTPickerMon.Value
  .Cells(lRow, 8).Value = Me.DTPickerTue.Value
  .Cells(lRow, 10).Value = Me.DTPickerWen.Value
  .Cells(lRow, 12).Value = Me.DTPickerThu.Value
  .Cells(lRow, 14).Value = Me.DTPickerFri.Value
  .Cells(lRow, 16).Value = Me.DTPickerSat.Value
  .Cells(lRow, 3).Value = Me.cboProgram.Value
What I am looking for is a loop (i think) that will repeat " cboEmployID,cboEmployID.List(lPart, 1),cboProgram" in columns A:C and move each set of cboLocation & DTPicker to a new row to populate in Columns D:E
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,217,391
Messages
6,136,321
Members
450,005
Latest member
BigPaws

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