variable inside a variable

bradley7

Board Regular
Joined
Feb 22, 2005
Messages
102
hi guys

can someone help me with thiis

endPart = "cboItems" & loopn & ".text" (where loopn is 1 to 5)
Jobs(1).JobMoreInfo(1).JobShortDesc = Value(endPart)

cboItems1 to 5 are combo boxs

I trying to do the above in a loop

should be
Jobs(1).JobMoreInfo(1).JobShortDesc = cboItems1.text
but i get the value in Jobs(1).JobMoreInfo(1).JobShortDesc as "cboItems01.text"
not the actual value of cboItems1.text.

i thought it may be
Jobs(1).JobMoreInfo(1).JobShortDesc = value(endPart) but is getting an error


Brad
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
untested:
endPart = "cboItems" & loopn '(where loopn is 1 to 5)
Jobs(1).JobMoreInfo(1).JobShortDesc = Me.Controls(endPart).Text

or forget setting endpart:
Jobs(1).JobMoreInfo(1).JobShortDesc = Me.Controls("cboItems" & loopn).Text

(Me. might screw things up depending on where the code is)
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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