+ Reply to Thread
Results 1 to 7 of 7

Checkbox question

  1. #1
    Patrick Simonds
    Guest

    Checkbox question

    On my userform initialize code, I want to have the checkbox value to be true
    (checked) if there is something in the referenced cell. I populate my
    textboxes with:

    TextBox5.Text = rng(1, 2).Value

    but not sure how to do this with a checkbox.



  2. #2
    Dave Peterson
    Guest

    Re: Checkbox question

    Maybe something like:

    Option Explicit
    Private Sub UserForm_Initialize()
    Me.CheckBox1.Value = CBool(Worksheets("sheet1").Range("a1").Value <> "")
    End Sub



    Patrick Simonds wrote:
    >
    > On my userform initialize code, I want to have the checkbox value to be true
    > (checked) if there is something in the referenced cell. I populate my
    > textboxes with:
    >
    > TextBox5.Text = rng(1, 2).Value
    >
    > but not sure how to do this with a checkbox.


    --

    Dave Peterson

  3. #3
    Patrick Simonds
    Guest

    Re: Checkbox question

    I can not reference a set cell, it will always go to the same column, but
    the row will be determined by which row the curser is on. That is why I was
    trying the rng(1, 2). For this Checkbox it will always look at column 2 of
    the current row.



    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > Maybe something like:
    >
    > Option Explicit
    > Private Sub UserForm_Initialize()
    > Me.CheckBox1.Value = CBool(Worksheets("sheet1").Range("a1").Value <>
    > "")
    > End Sub
    >
    >
    >
    > Patrick Simonds wrote:
    >>
    >> On my userform initialize code, I want to have the checkbox value to be
    >> true
    >> (checked) if there is something in the referenced cell. I populate my
    >> textboxes with:
    >>
    >> TextBox5.Text = rng(1, 2).Value
    >>
    >> but not sure how to do this with a checkbox.

    >
    > --
    >
    > Dave Peterson




  4. #4
    Patrick Simonds
    Guest

    Re: Checkbox question

    I should mention that I use the following to define rng:

    Dim rng
    Set rng = Cells(ActiveCell.Row, 1)


    "Patrick Simonds" <[email protected]> wrote in message
    news:[email protected]...
    >I can not reference a set cell, it will always go to the same column, but
    >the row will be determined by which row the curser is on. That is why I
    >was trying the rng(1, 2). For this Checkbox it will always look at column
    >2 of the current row.
    >
    >
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    >> Maybe something like:
    >>
    >> Option Explicit
    >> Private Sub UserForm_Initialize()
    >> Me.CheckBox1.Value = CBool(Worksheets("sheet1").Range("a1").Value <>
    >> "")
    >> End Sub
    >>
    >>
    >>
    >> Patrick Simonds wrote:
    >>>
    >>> On my userform initialize code, I want to have the checkbox value to be
    >>> true
    >>> (checked) if there is something in the referenced cell. I populate my
    >>> textboxes with:
    >>>
    >>> TextBox5.Text = rng(1, 2).Value
    >>>
    >>> but not sure how to do this with a checkbox.

    >>
    >> --
    >>
    >> Dave Peterson

    >
    >




  5. #5
    Mike Fogleman
    Guest

    Re: Checkbox question

    Try Daves solution with these modifications:

    Option Explicit
    Public rng As Range
    Private Sub UserForm_Initialize()
    Me.CheckBox1.Value = CBool(Worksheets("sheet1").Range(rng).Value <> "")
    End Sub

    Mike F

    "Patrick Simonds" <[email protected]> wrote in message
    news:[email protected]...
    >I should mention that I use the following to define rng:
    >
    > Dim rng
    > Set rng = Cells(ActiveCell.Row, 1)
    >
    >
    > "Patrick Simonds" <[email protected]> wrote in message
    > news:[email protected]...
    >>I can not reference a set cell, it will always go to the same column, but
    >>the row will be determined by which row the curser is on. That is why I
    >>was trying the rng(1, 2). For this Checkbox it will always look at column
    >>2 of the current row.
    >>
    >>
    >>
    >> "Dave Peterson" <[email protected]> wrote in message
    >> news:[email protected]...
    >>> Maybe something like:
    >>>
    >>> Option Explicit
    >>> Private Sub UserForm_Initialize()
    >>> Me.CheckBox1.Value = CBool(Worksheets("sheet1").Range("a1").Value <>
    >>> "")
    >>> End Sub
    >>>
    >>>
    >>>
    >>> Patrick Simonds wrote:
    >>>>
    >>>> On my userform initialize code, I want to have the checkbox value to be
    >>>> true
    >>>> (checked) if there is something in the referenced cell. I populate my
    >>>> textboxes with:
    >>>>
    >>>> TextBox5.Text = rng(1, 2).Value
    >>>>
    >>>> but not sure how to do this with a checkbox.
    >>>
    >>> --
    >>>
    >>> Dave Peterson

    >>
    >>

    >
    >




  6. #6
    Dave Peterson
    Guest

    Re: Checkbox question

    or maybe:


    Option Explicit
    Private Sub UserForm_Initialize()
    dim rng as range
    Set rng = activesheet.Cells(ActiveCell.Row, 1)
    Me.CheckBox1.Value = CBool(rng(1,2).Value <> "")
    End Sub



    Patrick Simonds wrote:
    >
    > I should mention that I use the following to define rng:
    >
    > Dim rng
    > Set rng = Cells(ActiveCell.Row, 1)
    >
    > "Patrick Simonds" <[email protected]> wrote in message
    > news:[email protected]...
    > >I can not reference a set cell, it will always go to the same column, but
    > >the row will be determined by which row the curser is on. That is why I
    > >was trying the rng(1, 2). For this Checkbox it will always look at column
    > >2 of the current row.
    > >
    > >
    > >
    > > "Dave Peterson" <[email protected]> wrote in message
    > > news:[email protected]...
    > >> Maybe something like:
    > >>
    > >> Option Explicit
    > >> Private Sub UserForm_Initialize()
    > >> Me.CheckBox1.Value = CBool(Worksheets("sheet1").Range("a1").Value <>
    > >> "")
    > >> End Sub
    > >>
    > >>
    > >>
    > >> Patrick Simonds wrote:
    > >>>
    > >>> On my userform initialize code, I want to have the checkbox value to be
    > >>> true
    > >>> (checked) if there is something in the referenced cell. I populate my
    > >>> textboxes with:
    > >>>
    > >>> TextBox5.Text = rng(1, 2).Value
    > >>>
    > >>> but not sure how to do this with a checkbox.
    > >>
    > >> --
    > >>
    > >> Dave Peterson

    > >
    > >


    --

    Dave Peterson

  7. #7
    Patrick Simonds
    Guest

    Re: Checkbox question

    I want to thank you all, Me.CheckBox1.Value = CBool(rng(1,2).Value <> "")
    was what it took to make this work.


    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > or maybe:
    >
    >
    > Option Explicit
    > Private Sub UserForm_Initialize()
    > dim rng as range
    > Set rng = activesheet.Cells(ActiveCell.Row, 1)
    > Me.CheckBox1.Value = CBool(rng(1,2).Value <> "")
    > End Sub
    >
    >
    >
    > Patrick Simonds wrote:
    >>
    >> I should mention that I use the following to define rng:
    >>
    >> Dim rng
    >> Set rng = Cells(ActiveCell.Row, 1)
    >>
    >> "Patrick Simonds" <[email protected]> wrote in message
    >> news:[email protected]...
    >> >I can not reference a set cell, it will always go to the same column,
    >> >but
    >> >the row will be determined by which row the curser is on. That is why I
    >> >was trying the rng(1, 2). For this Checkbox it will always look at
    >> >column
    >> >2 of the current row.
    >> >
    >> >
    >> >
    >> > "Dave Peterson" <[email protected]> wrote in message
    >> > news:[email protected]...
    >> >> Maybe something like:
    >> >>
    >> >> Option Explicit
    >> >> Private Sub UserForm_Initialize()
    >> >> Me.CheckBox1.Value = CBool(Worksheets("sheet1").Range("a1").Value
    >> >> <>
    >> >> "")
    >> >> End Sub
    >> >>
    >> >>
    >> >>
    >> >> Patrick Simonds wrote:
    >> >>>
    >> >>> On my userform initialize code, I want to have the checkbox value to
    >> >>> be
    >> >>> true
    >> >>> (checked) if there is something in the referenced cell. I populate my
    >> >>> textboxes with:
    >> >>>
    >> >>> TextBox5.Text = rng(1, 2).Value
    >> >>>
    >> >>> but not sure how to do this with a checkbox.
    >> >>
    >> >> --
    >> >>
    >> >> Dave Peterson
    >> >
    >> >

    >
    > --
    >
    > Dave Peterson




+ 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