PC Review


Reply
Thread Tools Rate Thread

Checkbox variable number

 
 
=?Utf-8?B?Y2Fyb2xpbmU=?=
Guest
Posts: n/a
 
      10th Sep 2007
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      10th Sep 2007
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 With Quote
 
=?Utf-8?B?Y2Fyb2xpbmU=?=
Guest
Posts: n/a
 
      10th Sep 2007
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 With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      10th Sep 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox variable Basta1980 Microsoft Excel Programming 1 30th Dec 2009 07:10 AM
Error Number: 91 object variable or With block Variable not set Hifni Microsoft Excel Programming 1 9th Jan 2008 11:56 AM
Re: making checkbox into a variable minastirith Microsoft Excel Programming 1 30th May 2006 04:30 PM
Use Variable In CheckBox Name mudraker Microsoft Excel Programming 1 2nd Apr 2006 03:01 PM
Extract variable number of chars from variable start position? Ann Scharpf Microsoft Excel Worksheet Functions 9 25th Feb 2004 02:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:10 PM.