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

I created a form with 10 check boxes in Excel. The CheckBox name is index 1
to 10. Then, I wrote a For next statement in the VBA code to list the checked
CheckBox(s). However, I encounter problem at the below code (the macro will
not recognize the "CheckBox(X)"). Why?

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


Thanks,
HK
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA code for check boxes in a form

In a userform?

You could use:

if me.controls("Checkbox" & x).value = true then



HKS wrote:

I created a form with 10 check boxes in Excel. The CheckBox name is index 1
to 10. Then, I wrote a For next statement in the VBA code to list the checked
CheckBox(s). However, I encounter problem at the below code (the macro will
not recognize the "CheckBox(X)"). Why?

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

Thanks,
HK


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
HKS HKS is offline
external usenet poster
 
Posts: 10
Default VBA code for check boxes in a form

Thanks a lot Dave!, it works

"Dave Peterson" wrote:

In a userform?

You could use:

if me.controls("Checkbox" & x).value = true then



HKS wrote:

I created a form with 10 check boxes in Excel. The CheckBox name is index 1
to 10. Then, I wrote a For next statement in the VBA code to list the checked
CheckBox(s). However, I encounter problem at the below code (the macro will
not recognize the "CheckBox(X)"). Why?

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

Thanks,
HK


--

Dave Peterson

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
VBA for form check boxes dicko1 Excel Worksheet Functions 4 June 5th 09 04:02 PM
VBA code for the Check Boxes in a form HKS Excel Discussion (Misc queries) 3 June 24th 08 09:42 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
Form Check Boxes an a worksheet Kevin McCartney Excel Programming 4 December 13th 05 01:20 PM
Can I Group Form Check Boxes? JK Excel Programming 1 August 23rd 04 07:02 PM


All times are GMT +1. The time now is 05:40 AM.

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"