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

Hi All

New to the world of programming on an excel worksheet. I am trying to set up
an array that contains checkboxes, basically I have checkboxes on a worksheet
on three different rows and I want to scroll through the rows and use the row
number as the index number for the checkbox and pass that to another function.

Dim ChipEnabled(1 To 10) As CheckBox

Private Sub cmdLogon_Click()
Sheet4.SetUpWorkSheet
End sub

Public Sub SetUpWorkSheet()

'Assign each check box to the ChipEnabled array
Set ChipEnabled(1) = chkChipVisaEnabled
Set ChipEnabled(2) = chkChipElectronEnabled
Set ChipEnabled(3) = chkChipMastercardEnabled

End Sub

When I the code gets to the first line Set ChipEnabled(1) =
chkChipVisaEnabled I get a Type Mismatch. I don't understand why.

If this was working I could then use this as follows.

For i = 1 to sheet1.Rows.Count
Update (ChipEnabled(i).Value)
Next i

I hope you understand what I mean.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Checkbox arrays

there are two types of Checkboxes. Change your declaration to

Dim ChipEnabled(1 To 10) As MSForm.CheckBox

--
Regards,
Tom Ogilvy


"David Bland" wrote:

Hi All

New to the world of programming on an excel worksheet. I am trying to set up
an array that contains checkboxes, basically I have checkboxes on a worksheet
on three different rows and I want to scroll through the rows and use the row
number as the index number for the checkbox and pass that to another function.

Dim ChipEnabled(1 To 10) As CheckBox

Private Sub cmdLogon_Click()
Sheet4.SetUpWorkSheet
End sub

Public Sub SetUpWorkSheet()

'Assign each check box to the ChipEnabled array
Set ChipEnabled(1) = chkChipVisaEnabled
Set ChipEnabled(2) = chkChipElectronEnabled
Set ChipEnabled(3) = chkChipMastercardEnabled

End Sub

When I the code gets to the first line Set ChipEnabled(1) =
chkChipVisaEnabled I get a Type Mismatch. I don't understand why.

If this was working I could then use this as follows.

For i = 1 to sheet1.Rows.Count
Update (ChipEnabled(i).Value)
Next i

I hope you understand what I mean.

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

Declare it as MSForms

Dim ChipEnabled(1 To 10) As MSForms.CheckBox

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"David Bland" wrote in message
...
Hi All

New to the world of programming on an excel worksheet. I am trying to set

up
an array that contains checkboxes, basically I have checkboxes on a

worksheet
on three different rows and I want to scroll through the rows and use the

row
number as the index number for the checkbox and pass that to another

function.

Dim ChipEnabled(1 To 10) As CheckBox

Private Sub cmdLogon_Click()
Sheet4.SetUpWorkSheet
End sub

Public Sub SetUpWorkSheet()

'Assign each check box to the ChipEnabled array
Set ChipEnabled(1) = chkChipVisaEnabled
Set ChipEnabled(2) = chkChipElectronEnabled
Set ChipEnabled(3) = chkChipMastercardEnabled

End Sub

When I the code gets to the first line Set ChipEnabled(1) =
chkChipVisaEnabled I get a Type Mismatch. I don't understand why.

If this was working I could then use this as follows.

For i = 1 to sheet1.Rows.Count
Update (ChipEnabled(i).Value)
Next i

I hope you understand what I mean.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Checkbox arrays



"Tom Ogilvy" wrote:

there are two types of Checkboxes. Change your declaration to

Dim ChipEnabled(1 To 10) As MSForm.CheckBox

--
Regards,
Tom Ogilvy


"David Bland" wrote:

Hi All

New to the world of programming on an excel worksheet. I am trying to set up
an array that contains checkboxes, basically I have checkboxes on a worksheet
on three different rows and I want to scroll through the rows and use the row
number as the index number for the checkbox and pass that to another function.

Dim ChipEnabled(1 To 10) As CheckBox

Private Sub cmdLogon_Click()
Sheet4.SetUpWorkSheet
End sub

Public Sub SetUpWorkSheet()

'Assign each check box to the ChipEnabled array
Set ChipEnabled(1) = chkChipVisaEnabled
Set ChipEnabled(2) = chkChipElectronEnabled
Set ChipEnabled(3) = chkChipMastercardEnabled

End Sub

When I the code gets to the first line Set ChipEnabled(1) =
chkChipVisaEnabled I get a Type Mismatch. I don't understand why.

If this was working I could then use this as follows.

For i = 1 to sheet1.Rows.Count
Update (ChipEnabled(i).Value)
Next i

I hope you understand what I mean.


Thanks Tom sorted it out a treat.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Checkbox arrays

for completeness, there was a typo

Dim ChipEnabled(1 To 10) As MSForm.CheckBox

should have been

Dim ChipEnabled(1 To 10) As MSForms.CheckBox

with an "s" on MSform

--
Regards,
Tom Ogilvy


Glad you figured it out.
--
Regards,
Tom Ogilvy





"David Bland" wrote:



"Tom Ogilvy" wrote:

there are two types of Checkboxes. Change your declaration to

Dim ChipEnabled(1 To 10) As MSForm.CheckBox

--
Regards,
Tom Ogilvy


"David Bland" wrote:

Hi All

New to the world of programming on an excel worksheet. I am trying to set up
an array that contains checkboxes, basically I have checkboxes on a worksheet
on three different rows and I want to scroll through the rows and use the row
number as the index number for the checkbox and pass that to another function.

Dim ChipEnabled(1 To 10) As CheckBox

Private Sub cmdLogon_Click()
Sheet4.SetUpWorkSheet
End sub

Public Sub SetUpWorkSheet()

'Assign each check box to the ChipEnabled array
Set ChipEnabled(1) = chkChipVisaEnabled
Set ChipEnabled(2) = chkChipElectronEnabled
Set ChipEnabled(3) = chkChipMastercardEnabled

End Sub

When I the code gets to the first line Set ChipEnabled(1) =
chkChipVisaEnabled I get a Type Mismatch. I don't understand why.

If this was working I could then use this as follows.

For i = 1 to sheet1.Rows.Count
Update (ChipEnabled(i).Value)
Next i

I hope you understand what I mean.


Thanks Tom sorted it out a treat.

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
Checkbox tinks Excel Discussion (Misc queries) 2 December 1st 09 06:31 PM
How to have Checkbox A uncheck with checked Checkbox B Texas Aggie Excel Discussion (Misc queries) 3 July 20th 07 10:58 PM
checkbox on form reset from checkbox on sheet raw[_12_] Excel Programming 1 December 3rd 05 05:08 AM
vba checkbox gareth thomson Excel Programming 2 September 29th 04 09:51 PM
checkbox mark Excel Programming 1 August 1st 03 09:47 PM


All times are GMT +1. The time now is 02:04 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"