+ Reply to Thread
Results 1 to 10 of 10

Looping through a group of checkboxes

  1. #1
    asdfasdf
    Guest

    Looping through a group of checkboxes

    I'm trying to loop through a group of checkboxes, but i'm having trouble
    figuring out how to go about it.

    here is my current code:

    Dim o As OLEObject
    Dim iCCCount, iCCColumn As Integer
    Dim iCGCount, iCGColumn As Integer
    iCCCount = 1
    iCCColumn = 1
    iCGCount = 1
    iCGColumn = 1
    'MsgBox cgAdvertiser.Caption
    Dim c As CheckBox
    For Each o In Sheet1.OLEObjects
    If TypeName(o.Object) = "CheckBox" Then
    If c.GroupName = "CG" Then
    iCGCount = iCGCount + 1
    End If
    End If
    Next

    so when it finds the type checkbox object i want to get the groupname.
    however i get an error telling me that object var or with var is not set.

    any help woulb be appreciated.
    thanks





  2. #2
    Tushar Mehta
    Guest

    Re: Looping through a group of checkboxes

    Where are you initializing the variable 'c'?

    --
    Regards,

    Tushar Mehta
    www.tushar-mehta.com
    Excel, PowerPoint, and VBA add-ins, tutorials
    Custom MS Office productivity solutions

    In article <[email protected]>, [email protected]
    says...
    > I'm trying to loop through a group of checkboxes, but i'm having trouble
    > figuring out how to go about it.
    >
    > here is my current code:
    >
    > Dim o As OLEObject
    > Dim iCCCount, iCCColumn As Integer
    > Dim iCGCount, iCGColumn As Integer
    > iCCCount = 1
    > iCCColumn = 1
    > iCGCount = 1
    > iCGColumn = 1
    > 'MsgBox cgAdvertiser.Caption
    > Dim c As CheckBox
    > For Each o In Sheet1.OLEObjects
    > If TypeName(o.Object) = "CheckBox" Then
    > If c.GroupName = "CG" Then
    > iCGCount = iCGCount + 1
    > End If
    > End If
    > Next
    >
    > so when it finds the type checkbox object i want to get the groupname.
    > however i get an error telling me that object var or with var is not set.
    >
    > any help woulb be appreciated.
    > thanks
    >
    >
    >
    >
    >


  3. #3
    JMB
    Guest

    RE: Looping through a group of checkboxes

    Maybe this will work

    If o.GroupName = "CG" Then

    "asdfasdf" wrote:

    > I'm trying to loop through a group of checkboxes, but i'm having trouble
    > figuring out how to go about it.
    >
    > here is my current code:
    >
    > Dim o As OLEObject
    > Dim iCCCount, iCCColumn As Integer
    > Dim iCGCount, iCGColumn As Integer
    > iCCCount = 1
    > iCCColumn = 1
    > iCGCount = 1
    > iCGColumn = 1
    > 'MsgBox cgAdvertiser.Caption
    > Dim c As CheckBox
    > For Each o In Sheet1.OLEObjects
    > If TypeName(o.Object) = "CheckBox" Then
    > If c.GroupName = "CG" Then
    > iCGCount = iCGCount + 1
    > End If
    > End If
    > Next
    >
    > so when it finds the type checkbox object i want to get the groupname.
    > however i get an error telling me that object var or with var is not set.
    >
    > any help woulb be appreciated.
    > thanks
    >
    >
    >
    >
    >


  4. #4
    asdfasdf
    Guest

    Re: Looping through a group of checkboxes

    I'm sorry, initially i was doing:
    Set c = o

    but i don't know how to cast the object to a checkbox object.


    "Tushar Mehta" <[email protected]> wrote in message
    news:[email protected]...
    > Where are you initializing the variable 'c'?
    >
    > --
    > Regards,
    >
    > Tushar Mehta
    > www.tushar-mehta.com
    > Excel, PowerPoint, and VBA add-ins, tutorials
    > Custom MS Office productivity solutions
    >
    > In article <[email protected]>, [email protected]
    > says...
    > > I'm trying to loop through a group of checkboxes, but i'm having trouble
    > > figuring out how to go about it.
    > >
    > > here is my current code:
    > >
    > > Dim o As OLEObject
    > > Dim iCCCount, iCCColumn As Integer
    > > Dim iCGCount, iCGColumn As Integer
    > > iCCCount = 1
    > > iCCColumn = 1
    > > iCGCount = 1
    > > iCGColumn = 1
    > > 'MsgBox cgAdvertiser.Caption
    > > Dim c As CheckBox
    > > For Each o In Sheet1.OLEObjects
    > > If TypeName(o.Object) = "CheckBox" Then
    > > If c.GroupName = "CG" Then
    > > iCGCount = iCGCount + 1
    > > End If
    > > End If
    > > Next
    > >
    > > so when it finds the type checkbox object i want to get the groupname.
    > > however i get an error telling me that object var or with var is not

    set.
    > >
    > > any help woulb be appreciated.
    > > thanks
    > >
    > >
    > >
    > >
    > >




  5. #5
    asdfasdf
    Guest

    Re: Looping through a group of checkboxes

    JMB:
    yea sorry i have tried so manythings that i am mixing code

    when i do o.GroupName...
    I get object doesn't support this propery or method

    "JMB" <[email protected]> wrote in message
    news:[email protected]...
    > Maybe this will work
    >
    > If o.GroupName = "CG" Then
    >
    > "asdfasdf" wrote:
    >
    > > I'm trying to loop through a group of checkboxes, but i'm having trouble
    > > figuring out how to go about it.
    > >
    > > here is my current code:
    > >
    > > Dim o As OLEObject
    > > Dim iCCCount, iCCColumn As Integer
    > > Dim iCGCount, iCGColumn As Integer
    > > iCCCount = 1
    > > iCCColumn = 1
    > > iCGCount = 1
    > > iCGColumn = 1
    > > 'MsgBox cgAdvertiser.Caption
    > > Dim c As CheckBox
    > > For Each o In Sheet1.OLEObjects
    > > If TypeName(o.Object) = "CheckBox" Then
    > > If c.GroupName = "CG" Then
    > > iCGCount = iCGCount + 1
    > > End If
    > > End If
    > > Next
    > >
    > > so when it finds the type checkbox object i want to get the groupname.
    > > however i get an error telling me that object var or with var is not

    set.
    > >
    > > any help woulb be appreciated.
    > > thanks
    > >
    > >
    > >
    > >
    > >




  6. #6
    JMB
    Guest

    Re: Looping through a group of checkboxes

    Try this.

    If o.Object.GroupName = "CG" Then


    "asdfasdf" wrote:

    > JMB:
    > yea sorry i have tried so manythings that i am mixing code
    >
    > when i do o.GroupName...
    > I get object doesn't support this propery or method
    >
    > "JMB" <[email protected]> wrote in message
    > news:[email protected]...
    > > Maybe this will work
    > >
    > > If o.GroupName = "CG" Then
    > >
    > > "asdfasdf" wrote:
    > >
    > > > I'm trying to loop through a group of checkboxes, but i'm having trouble
    > > > figuring out how to go about it.
    > > >
    > > > here is my current code:
    > > >
    > > > Dim o As OLEObject
    > > > Dim iCCCount, iCCColumn As Integer
    > > > Dim iCGCount, iCGColumn As Integer
    > > > iCCCount = 1
    > > > iCCColumn = 1
    > > > iCGCount = 1
    > > > iCGColumn = 1
    > > > 'MsgBox cgAdvertiser.Caption
    > > > Dim c As CheckBox
    > > > For Each o In Sheet1.OLEObjects
    > > > If TypeName(o.Object) = "CheckBox" Then
    > > > If c.GroupName = "CG" Then
    > > > iCGCount = iCGCount + 1
    > > > End If
    > > > End If
    > > > Next
    > > >
    > > > so when it finds the type checkbox object i want to get the groupname.
    > > > however i get an error telling me that object var or with var is not

    > set.
    > > >
    > > > any help woulb be appreciated.
    > > > thanks
    > > >
    > > >
    > > >
    > > >
    > > >

    >
    >
    >


  7. #7
    Tushar Mehta
    Guest

    Re: Looping through a group of checkboxes

    A checkbox cannot be part of a group. If you check XL VBA help for
    groupname you will find it only applies to an optionbutton.

    --
    Regards,

    Tushar Mehta
    www.tushar-mehta.com
    Excel, PowerPoint, and VBA add-ins, tutorials
    Custom MS Office productivity solutions

    In article <[email protected]>, [email protected]
    says...
    > I'm sorry, initially i was doing:
    > Set c = o
    >
    > but i don't know how to cast the object to a checkbox object.
    >
    >
    > "Tushar Mehta" <[email protected]> wrote in message
    > news:[email protected]...
    > > Where are you initializing the variable 'c'?
    > >
    > > --
    > > Regards,
    > >
    > > Tushar Mehta
    > > www.tushar-mehta.com
    > > Excel, PowerPoint, and VBA add-ins, tutorials
    > > Custom MS Office productivity solutions
    > >
    > > In article <[email protected]>, [email protected]
    > > says...
    > > > I'm trying to loop through a group of checkboxes, but i'm having trouble
    > > > figuring out how to go about it.
    > > >
    > > > here is my current code:
    > > >
    > > > Dim o As OLEObject
    > > > Dim iCCCount, iCCColumn As Integer
    > > > Dim iCGCount, iCGColumn As Integer
    > > > iCCCount = 1
    > > > iCCColumn = 1
    > > > iCGCount = 1
    > > > iCGColumn = 1
    > > > 'MsgBox cgAdvertiser.Caption
    > > > Dim c As CheckBox
    > > > For Each o In Sheet1.OLEObjects
    > > > If TypeName(o.Object) = "CheckBox" Then
    > > > If c.GroupName = "CG" Then
    > > > iCGCount = iCGCount + 1
    > > > End If
    > > > End If
    > > > Next
    > > >
    > > > so when it finds the type checkbox object i want to get the groupname.
    > > > however i get an error telling me that object var or with var is not

    > set.
    > > >
    > > > any help woulb be appreciated.
    > > > thanks
    > > >
    > > >
    > > >
    > > >
    > > >

    >
    >
    >


  8. #8
    asdfasdf
    Guest

    Re: Looping through a group of checkboxes

    JMB ahhh awesome that worked!!! thanks a bunch!


    "JMB" <[email protected]> wrote in message
    news:[email protected]...
    > Try this.
    >
    > If o.Object.GroupName = "CG" Then
    >
    >
    > "asdfasdf" wrote:
    >
    > > JMB:
    > > yea sorry i have tried so manythings that i am mixing code
    > >
    > > when i do o.GroupName...
    > > I get object doesn't support this propery or method
    > >
    > > "JMB" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Maybe this will work
    > > >
    > > > If o.GroupName = "CG" Then
    > > >
    > > > "asdfasdf" wrote:
    > > >
    > > > > I'm trying to loop through a group of checkboxes, but i'm having

    trouble
    > > > > figuring out how to go about it.
    > > > >
    > > > > here is my current code:
    > > > >
    > > > > Dim o As OLEObject
    > > > > Dim iCCCount, iCCColumn As Integer
    > > > > Dim iCGCount, iCGColumn As Integer
    > > > > iCCCount = 1
    > > > > iCCColumn = 1
    > > > > iCGCount = 1
    > > > > iCGColumn = 1
    > > > > 'MsgBox cgAdvertiser.Caption
    > > > > Dim c As CheckBox
    > > > > For Each o In Sheet1.OLEObjects
    > > > > If TypeName(o.Object) = "CheckBox" Then
    > > > > If c.GroupName = "CG" Then
    > > > > iCGCount = iCGCount + 1
    > > > > End If
    > > > > End If
    > > > > Next
    > > > >
    > > > > so when it finds the type checkbox object i want to get the

    groupname.
    > > > > however i get an error telling me that object var or with var is not

    > > set.
    > > > >
    > > > > any help woulb be appreciated.
    > > > > thanks
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >




  9. #9
    asdfasdf
    Guest

    Re: Looping through a group of checkboxes

    I might not explictly be able to group them, but i can at least give the
    group of checkbox's a group name and check for that group name. if my
    checkbox is in that group, then i can do stuff to that checkbox based upon
    the group. i.e. put it in another sheet in a specific area.

    "Tushar Mehta" <[email protected]> wrote in message
    news:[email protected]...
    > A checkbox cannot be part of a group. If you check XL VBA help for
    > groupname you will find it only applies to an optionbutton.
    >
    > --
    > Regards,
    >
    > Tushar Mehta
    > www.tushar-mehta.com
    > Excel, PowerPoint, and VBA add-ins, tutorials
    > Custom MS Office productivity solutions
    >
    > In article <[email protected]>, [email protected]
    > says...
    > > I'm sorry, initially i was doing:
    > > Set c = o
    > >
    > > but i don't know how to cast the object to a checkbox object.
    > >
    > >
    > > "Tushar Mehta" <[email protected]> wrote in

    message
    > > news:[email protected]...
    > > > Where are you initializing the variable 'c'?
    > > >
    > > > --
    > > > Regards,
    > > >
    > > > Tushar Mehta
    > > > www.tushar-mehta.com
    > > > Excel, PowerPoint, and VBA add-ins, tutorials
    > > > Custom MS Office productivity solutions
    > > >
    > > > In article <[email protected]>,

    [email protected]
    > > > says...
    > > > > I'm trying to loop through a group of checkboxes, but i'm having

    trouble
    > > > > figuring out how to go about it.
    > > > >
    > > > > here is my current code:
    > > > >
    > > > > Dim o As OLEObject
    > > > > Dim iCCCount, iCCColumn As Integer
    > > > > Dim iCGCount, iCGColumn As Integer
    > > > > iCCCount = 1
    > > > > iCCColumn = 1
    > > > > iCGCount = 1
    > > > > iCGColumn = 1
    > > > > 'MsgBox cgAdvertiser.Caption
    > > > > Dim c As CheckBox
    > > > > For Each o In Sheet1.OLEObjects
    > > > > If TypeName(o.Object) = "CheckBox" Then
    > > > > If c.GroupName = "CG" Then
    > > > > iCGCount = iCGCount + 1
    > > > > End If
    > > > > End If
    > > > > Next
    > > > >
    > > > > so when it finds the type checkbox object i want to get the

    groupname.
    > > > > however i get an error telling me that object var or with var is not

    > > set.
    > > > >
    > > > > any help woulb be appreciated.
    > > > > thanks
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >




  10. #10
    JMB
    Guest

    Re: Looping through a group of checkboxes

    you're welcome.

    "asdfasdf" wrote:

    > JMB ahhh awesome that worked!!! thanks a bunch!
    >
    >
    > "JMB" <[email protected]> wrote in message
    > news:[email protected]...
    > > Try this.
    > >
    > > If o.Object.GroupName = "CG" Then
    > >
    > >
    > > "asdfasdf" wrote:
    > >
    > > > JMB:
    > > > yea sorry i have tried so manythings that i am mixing code
    > > >
    > > > when i do o.GroupName...
    > > > I get object doesn't support this propery or method
    > > >
    > > > "JMB" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > Maybe this will work
    > > > >
    > > > > If o.GroupName = "CG" Then
    > > > >
    > > > > "asdfasdf" wrote:
    > > > >
    > > > > > I'm trying to loop through a group of checkboxes, but i'm having

    > trouble
    > > > > > figuring out how to go about it.
    > > > > >
    > > > > > here is my current code:
    > > > > >
    > > > > > Dim o As OLEObject
    > > > > > Dim iCCCount, iCCColumn As Integer
    > > > > > Dim iCGCount, iCGColumn As Integer
    > > > > > iCCCount = 1
    > > > > > iCCColumn = 1
    > > > > > iCGCount = 1
    > > > > > iCGColumn = 1
    > > > > > 'MsgBox cgAdvertiser.Caption
    > > > > > Dim c As CheckBox
    > > > > > For Each o In Sheet1.OLEObjects
    > > > > > If TypeName(o.Object) = "CheckBox" Then
    > > > > > If c.GroupName = "CG" Then
    > > > > > iCGCount = iCGCount + 1
    > > > > > End If
    > > > > > End If
    > > > > > Next
    > > > > >
    > > > > > so when it finds the type checkbox object i want to get the

    > groupname.
    > > > > > however i get an error telling me that object var or with var is not
    > > > set.
    > > > > >
    > > > > > any help woulb be appreciated.
    > > > > > thanks
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1