+ Reply to Thread
Results 1 to 4 of 4

UserForm Intialization

  1. #1
    Patrick Simonds
    Guest

    UserForm Intialization

    Why does the code below not set OptionButton1.Value to True?

    Private Sub UserForm_Initialize()

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

    TextBox1.Text = rng(1, 1).Text
    TextBox2.Text = rng(1, 2).Text
    TextBox3.Text = rng(1, 4).Text

    If rng(1, 3) = "member" Then
    OptionButton1.Value = True
    End If

    End Sub

  2. #2
    Tom Ogilvy
    Guest

    RE: UserForm Intialization

    the obvious answer is that rng(1,3) = "member"
    even though you might think it does. (extra space?, activecell not what you
    think it is? )

    --
    Regards,
    Tom Ogilvy




    "Patrick Simonds" wrote:

    > Why does the code below not set OptionButton1.Value to True?
    >
    > Private Sub UserForm_Initialize()
    >
    > Dim rng
    > Set rng = Cells(ActiveCell.Row, 1)
    >
    > TextBox1.Text = rng(1, 1).Text
    > TextBox2.Text = rng(1, 2).Text
    > TextBox3.Text = rng(1, 4).Text
    >
    > If rng(1, 3) = "member" Then
    > OptionButton1.Value = True
    > End If
    >
    > End Sub


  3. #3
    Patrick Simonds
    Guest

    Re: UserForm Intialization

    Turns out it case case sensative. The rng(1, 3) contained the word Member
    not member


    "Tom Ogilvy" <TomOgilvy@discussions.microsoft.com> wrote in message
    news:403B09A7-040B-4B62-9D74-F1BFE906C2BF@microsoft.com...
    > the obvious answer is that rng(1,3) = "member"
    > even though you might think it does. (extra space?, activecell not what
    > you
    > think it is? )
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    >
    > "Patrick Simonds" wrote:
    >
    >> Why does the code below not set OptionButton1.Value to True?
    >>
    >> Private Sub UserForm_Initialize()
    >>
    >> Dim rng
    >> Set rng = Cells(ActiveCell.Row, 1)
    >>
    >> TextBox1.Text = rng(1, 1).Text
    >> TextBox2.Text = rng(1, 2).Text
    >> TextBox3.Text = rng(1, 4).Text
    >>
    >> If rng(1, 3) = "member" Then
    >> OptionButton1.Value = True
    >> End If
    >>
    >> End Sub




  4. #4
    Tom Ogilvy
    Guest

    Re: UserForm Intialization

    There you go! <g>

    Yes, equality of strings is case sensitive unless you change with declare

    Option Compare Text

    at the top of the module

    better probably is you can make it case insensitive with

    if lcase(rng(1,3)) = "member" then


    --
    Regards,
    Tom Ogilvy

    "Patrick Simonds" <ordnance1@comcast.net> wrote in message
    news:el$5QStgGHA.2040@TK2MSFTNGP03.phx.gbl...
    > Turns out it case case sensative. The rng(1, 3) contained the word Member
    > not member
    >
    >
    > "Tom Ogilvy" <TomOgilvy@discussions.microsoft.com> wrote in message
    > news:403B09A7-040B-4B62-9D74-F1BFE906C2BF@microsoft.com...
    > > the obvious answer is that rng(1,3) = "member"
    > > even though you might think it does. (extra space?, activecell not what
    > > you
    > > think it is? )
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > >
    > >
    > > "Patrick Simonds" wrote:
    > >
    > >> Why does the code below not set OptionButton1.Value to True?
    > >>
    > >> Private Sub UserForm_Initialize()
    > >>
    > >> Dim rng
    > >> Set rng = Cells(ActiveCell.Row, 1)
    > >>
    > >> TextBox1.Text = rng(1, 1).Text
    > >> TextBox2.Text = rng(1, 2).Text
    > >> TextBox3.Text = rng(1, 4).Text
    > >>
    > >> If rng(1, 3) = "member" Then
    > >> OptionButton1.Value = True
    > >> End If
    > >>
    > >> End Sub

    >
    >




+ 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