Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VARIABLE SUBSTITUTION

Hi,
I have a form with 24 checkboxes. (CheckBox1...CheckBox24)
Is there a way to make the following work?
This works...
If CheckBox3 Then MsgBox "Three"
This doesn't...
i = 3
z = "CheckBox" & LTrim(Str(i))
If z Then MsgBox "Three"

Thank you



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default VARIABLE SUBSTITUTION

If the Checkboxes are in a userform, try this:

z = Me.Controls("CheckBox" & i).Object .Value


--
Regards,

Juan Pablo González

"Robert Lowe" wrote in message
...
Hi,
I have a form with 24 checkboxes. (CheckBox1...CheckBox24)
Is there a way to make the following work?
This works...
If CheckBox3 Then MsgBox "Three"
This doesn't...
i = 3
z = "CheckBox" & LTrim(Str(i))
If z Then MsgBox "Three"

Thank you





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VARIABLE SUBSTITUTION

Robert,

This is how you do it

If Me.Controls("Checkbox" & i).Value = True Then
MsgBox "Found"
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Robert Lowe" wrote in message
...
Hi,
I have a form with 24 checkboxes. (CheckBox1...CheckBox24)
Is there a way to make the following work?
This works...
If CheckBox3 Then MsgBox "Three"
This doesn't...
i = 3
z = "CheckBox" & LTrim(Str(i))
If z Then MsgBox "Three"

Thank you





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VARIABLE SUBSTITUTION

Thank a lot...
It works great. I would never have gotten it!
I have MUCH to learn....
Robert

"Juan Pablo Gonzalez" wrote in message
...
If the Checkboxes are in a userform, try this:

z = Me.Controls("CheckBox" & i).Object .Value


--
Regards,

Juan Pablo González

"Robert Lowe" wrote in message
...
Hi,
I have a form with 24 checkboxes. (CheckBox1...CheckBox24)
Is there a way to make the following work?
This works...
If CheckBox3 Then MsgBox "Three"
This doesn't...
i = 3
z = "CheckBox" & LTrim(Str(i))
If z Then MsgBox "Three"

Thank you







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable substitution doobie Excel Discussion (Misc queries) 1 November 9th 09 05:36 PM
variable substitution in a formula linking to external workbook my Excel Discussion (Misc queries) 2 August 29th 07 03:05 PM
variable substitution in a formula NHRunner Excel Discussion (Misc queries) 5 May 11th 07 01:56 PM
substitution Cossloffe Excel Discussion (Misc queries) 1 June 4th 06 07:10 AM
Cell/Variable content substitution Jim[_41_] Excel Programming 2 February 6th 04 07:13 PM


All times are GMT +1. The time now is 08:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"