Refer to Combo-box using a part + variable

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

I have 10 combo-boxes called:
CBoxOwner1, CBoxOwner2, CBoxOwner3 etc

I need to write the contents of each box (using a loop) to a sheet
using i as the loop variable to refer to the particular combo-box.
Obviously the segment:
CBoxOwner & i
doesn't work to refer to
CBoxOwner1
when i = 1 etc

For i = 1 To 10
Cells(i + 2, 3) = frmTransportRequest.CBoxOwner & i
Next i

Is it possible to do this within a loop?

Peter
 
Peter,

Try

Dim i As Integer
For i = 1 To 10
Cells(i,1).Value = frmTransportRequest.Controls("CBoxOwner" &
i).Text
Next i


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
Thanks Chip
I will give it a try.
Peter

Chip Pearson said:
Peter,

Try

Dim i As Integer
For i = 1 To 10
Cells(i,1).Value = frmTransportRequest.Controls("CBoxOwner" &
i).Text
Next i


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
Back
Top