![]() |
Refer to Combo-box using a part + variable
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 |
Refer to Combo-box using a part + variable
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 "Peter" wrote in message ... 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 |
Refer to Combo-box using a part + variable
Thanks Chip
I will give it a try. Peter Chip Pearson wrote in message ... 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 "Peter" wrote in message ... 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 |
Refer to Combo-box using a part + variable
Yep, it does the trick.
Thanks so much, Chip Peter Chip Pearson wrote in message ... 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 "Peter" wrote in message ... 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 |
All times are GMT +1. The time now is 10:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com