UserForm Intialization

P

Patrick Simonds

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
 
T

Tom Ogilvy

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? )
 
P

Patrick Simonds

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

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top