ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deriving a name from variables (https://www.excelbanter.com/excel-programming/436993-deriving-name-variables.html)

brichard429

Deriving a name from variables
 
I have 22 CheckBox objects named CheckBox1, CheckBox2 etc. I would like to
substitue a variable to represent the name in the expression
"Sheet2.TextBox1= False" by using a do loop and varying the number portion
of the word TextBox. Any suggestions?
--
Bernie

Dave Peterson

Deriving a name from variables
 
Checkboxes and textboxes from the control toolbox toolbar???

I'm not quite sure what you're doing, but maybe this will give you an idea:

Option Explicit
Sub testme()
Dim iCtr As Long
With Sheet2
For iCtr = 1 To 22
.OLEObjects("textbox" & iCtr).Object.Enabled _
= .OLEObjects("checkbox" & iCtr).Object.Value
Next iCtr
End With
End Sub




brichard429 wrote:

I have 22 CheckBox objects named CheckBox1, CheckBox2 etc. I would like to
substitue a variable to represent the name in the expression
"Sheet2.TextBox1= False" by using a do loop and varying the number portion
of the word TextBox. Any suggestions?
--
Bernie


--

Dave Peterson

brichard429

Deriving a name from variables
 
Thank You Dave. Here is the code I used to clear all of the 22 CheckBoxes of
checks using your suggestion.

Dim iCtr As Long
With Sheet2
For iCtr = 1 to 22
.OLEObjects("CheckBox" & iCtr).Object.Value = False
Next iCtr
End With
--
Bernie


"Dave Peterson" wrote:

Checkboxes and textboxes from the control toolbox toolbar???

I'm not quite sure what you're doing, but maybe this will give you an idea:

Option Explicit
Sub testme()
Dim iCtr As Long
With Sheet2
For iCtr = 1 To 22
.OLEObjects("textbox" & iCtr).Object.Enabled _
= .OLEObjects("checkbox" & iCtr).Object.Value
Next iCtr
End With
End Sub




brichard429 wrote:

I have 22 CheckBox objects named CheckBox1, CheckBox2 etc. I would like to
substitue a variable to represent the name in the expression
"Sheet2.TextBox1= False" by using a do loop and varying the number portion
of the word TextBox. Any suggestions?
--
Bernie


--

Dave Peterson
.



All times are GMT +1. The time now is 11:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com