Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
HKS HKS is offline
external usenet poster
 
Posts: 10
Default VBA code for the Check Boxes in a form

I created 10 checkboxes in the Excel form. The name of the checkboxes are
"CheckBox1...10." Then, I wrote the below For next statement in the VBA to
list the checked checkboxes name, but I encounterred problem, why?

For X = 1 To 10
If CheckBox(X) = True Then
Y = Y + 1 'Array counter
ReDim Preserve vArrayItem(0 To Y)
vArrayItem(Y) = CheckBox(X).Caption
End If
Next X


Thanks in advance
HKS
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default VBA code for the Check Boxes in a form

For X = 1 To 10
If CheckBox(X) = True Then
Y = Y + 1 'Array counter
ReDim Preserve vArrayItem(0 To Y)
vArrayItem(Y) = Controls("CheckBox" & X).Caption
End If
Next X


--
__________________________________
HTH

Bob

"HKS" wrote in message
...
I created 10 checkboxes in the Excel form. The name of the checkboxes are
"CheckBox1...10." Then, I wrote the below For next statement in the VBA to
list the checked checkboxes name, but I encounterred problem, why?

For X = 1 To 10
If CheckBox(X) = True Then
Y = Y + 1 'Array counter
ReDim Preserve vArrayItem(0 To Y)
vArrayItem(Y) = CheckBox(X).Caption
End If
Next X


Thanks in advance
HKS



  #3   Report Post  
Posted to microsoft.public.excel.misc
HKS HKS is offline
external usenet poster
 
Posts: 10
Default VBA code for the Check Boxes in a form

Using your suggestion, I modified one more line of code too.
if Controls("CheckBox" & X).value = true then

Thanks Bob!

"Bob Phillips" wrote:

For X = 1 To 10
If CheckBox(X) = True Then
Y = Y + 1 'Array counter
ReDim Preserve vArrayItem(0 To Y)
vArrayItem(Y) = Controls("CheckBox" & X).Caption
End If
Next X


--
__________________________________
HTH

Bob

"HKS" wrote in message
...
I created 10 checkboxes in the Excel form. The name of the checkboxes are
"CheckBox1...10." Then, I wrote the below For next statement in the VBA to
list the checked checkboxes name, but I encounterred problem, why?

For X = 1 To 10
If CheckBox(X) = True Then
Y = Y + 1 'Array counter
ReDim Preserve vArrayItem(0 To Y)
vArrayItem(Y) = CheckBox(X).Caption
End If
Next X


Thanks in advance
HKS




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default VBA code for the Check Boxes in a form

oops missed that bit, sorry but you got it <g

--
__________________________________
HTH

Bob

"HKS" wrote in message
...
Using your suggestion, I modified one more line of code too.
if Controls("CheckBox" & X).value = true then

Thanks Bob!

"Bob Phillips" wrote:

For X = 1 To 10
If CheckBox(X) = True Then
Y = Y + 1 'Array counter
ReDim Preserve vArrayItem(0 To Y)
vArrayItem(Y) = Controls("CheckBox" & X).Caption
End If
Next X


--
__________________________________
HTH

Bob

"HKS" wrote in message
...
I created 10 checkboxes in the Excel form. The name of the checkboxes
are
"CheckBox1...10." Then, I wrote the below For next statement in the VBA
to
list the checked checkboxes name, but I encounterred problem, why?

For X = 1 To 10
If CheckBox(X) = True Then
Y = Y + 1 'Array counter
ReDim Preserve vArrayItem(0 To Y)
vArrayItem(Y) = CheckBox(X).Caption
End If
Next X


Thanks in advance
HKS






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
copy check boxes (made from form toolbar) hoffjero Excel Discussion (Misc queries) 6 February 4th 09 11:20 PM
Add tab access to check boxes in a protected Excel sheet form. Suebriquet Excel Discussion (Misc queries) 0 July 25th 07 07:12 PM
How do I create a Form with check boxes in Excel Not Super User Excel Worksheet Functions 1 June 28th 07 05:08 PM
Enable check box in protected sheet + group check boxes Dexxterr Excel Discussion (Misc queries) 4 August 2nd 06 12:00 PM
How do I remove (form) check-boxes from multiple excel fields? ATSANAC Excel Discussion (Misc queries) 2 May 11th 06 06:48 PM


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

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

About Us

"It's about Microsoft Excel"