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

Hello,
I have 40 check boxes and I would like the following routine to be performed
when a check box is ticked.

Private Sub CheckBox1_Click()
Range(Range("Parameter1"), Range("Parameter1").Offset(0, 4)).Copy
Range("ParameterInput").PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

if checkbox1 is clicked I would like to copy the value from Parameter1, when
checkbox2 is clicked I would like to copy the value from Parameter2, and so
on.

is there an elegant way to do this without repeating 40 times the code?
thanks
--
caroline
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Checkbox variable number

This example uses commandbuttons on a userform, but you can do the same with
your situation: (view this as a technique/approach)

http://www.j-walk.com/ss/excel/tips/tip44.htm

--
Regards,
Tom Ogilvy


"caroline" wrote:

Hello,
I have 40 check boxes and I would like the following routine to be performed
when a check box is ticked.

Private Sub CheckBox1_Click()
Range(Range("Parameter1"), Range("Parameter1").Offset(0, 4)).Copy
Range("ParameterInput").PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

if checkbox1 is clicked I would like to copy the value from Parameter1, when
checkbox2 is clicked I would like to copy the value from Parameter2, and so
on.

is there an elegant way to do this without repeating 40 times the code?
thanks
--
caroline

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default Checkbox variable number

Thanks but I am not sure this can work in my case. I have other controls than
the checkboxes on my sheet.
any other idea?
thanks
--
caroline


"Tom Ogilvy" wrote:

This example uses commandbuttons on a userform, but you can do the same with
your situation: (view this as a technique/approach)

http://www.j-walk.com/ss/excel/tips/tip44.htm

--
Regards,
Tom Ogilvy


"caroline" wrote:

Hello,
I have 40 check boxes and I would like the following routine to be performed
when a check box is ticked.

Private Sub CheckBox1_Click()
Range(Range("Parameter1"), Range("Parameter1").Offset(0, 4)).Copy
Range("ParameterInput").PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

if checkbox1 is clicked I would like to copy the value from Parameter1, when
checkbox2 is clicked I would like to copy the value from Parameter2, and so
on.

is there an elegant way to do this without repeating 40 times the code?
thanks
--
caroline

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Checkbox variable number

No need for other ideas. It doesn't make any difference about other
controls. You write the macro to only add the controls you want to be
handled. Simple ways to implement this are to name the controls so the ones
to be handled have a unique text string in their name as an example. Then
when you loop throught the oleObjects collection, you only set up those
controls to be handled.



' Other ideas are writing multiple events.

--
Regards,
Tom Ogilvy


"caroline" wrote:

Thanks but I am not sure this can work in my case. I have other controls than
the checkboxes on my sheet.
any other idea?
thanks
--
caroline


"Tom Ogilvy" wrote:

This example uses commandbuttons on a userform, but you can do the same with
your situation: (view this as a technique/approach)

http://www.j-walk.com/ss/excel/tips/tip44.htm

--
Regards,
Tom Ogilvy


"caroline" wrote:

Hello,
I have 40 check boxes and I would like the following routine to be performed
when a check box is ticked.

Private Sub CheckBox1_Click()
Range(Range("Parameter1"), Range("Parameter1").Offset(0, 4)).Copy
Range("ParameterInput").PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

if checkbox1 is clicked I would like to copy the value from Parameter1, when
checkbox2 is clicked I would like to copy the value from Parameter2, and so
on.

is there an elegant way to do this without repeating 40 times the code?
thanks
--
caroline

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
making checkbox into a variable minastirith Excel Programming 1 May 30th 06 04:30 PM
making checkbox into a variable minastirith[_2_] Excel Programming 1 May 30th 06 04:30 PM
Use Variable In CheckBox Name mudraker[_353_] Excel Programming 1 April 2nd 06 03:01 PM
Use Checkbox Value or Public Variable? Stratuser Excel Programming 2 February 12th 04 02:33 PM
Using a variable to represent a Checkbox Name(OLEObject) Mike Cooper Excel Programming 1 July 16th 03 09:40 PM


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