Run-time error '424': Object required

Bonjelaku

New Member
Joined
Jun 27, 2008
Messages
2
Hi,

I tried a macro below and I got error message : Run-time error "424": Object required.

The macro is trying to verify the user name and password from user to input through a userform.

I used Excel 2003 with window XP.

This is part of the macro that got error: (highlighted & italic)

Rich (BB code):
Private Sub btnOK_Click()
Dim bError As Boolean
Dim sSName As String
Dim p As DocumentProperty
Dim bSetIt As Boolean
 
bOK2Use = False
bError = True
If Len(txtUser.Text) > 0 And Len(txtPass.Text) > 0 Then
bError = False
Select Case txtUser.Text
Case "user1"
sSName = "u1sheet"
If txtPass.Text <> "u1pass" Then bError = True
Case "user2"
sSName = "u2sheet"
If txtPass.Text <> "u2pass" Then bError = True
Case Else
bError = True
End Select
End If

And the error highlight the line : If Len(txtUser.Text) > 0 And Len(txtPass.Text) > 0 Then

I also tried to change the sheet tab name in excel, put variables in the maccro, but it didn't work.

Could someone please help this? Thank you very much.

BJ
 
Last edited by a moderator:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi and welcome to the board!!!
Code:
If Len(Range("txtUser").Text) > 0 And Len(Range("txtPass").Text) > 0 Then

or dim txtUser and txtPass as Range

lenze
 
Upvote 0
Welcome to the Board!

Are your text boxes actually named "txtUser" and "txtPass"?

If the names don't match the code that can cause an error.

Hope that helps,

(Have a great weekend Lenze!)
 
Upvote 0
Thank you for quick response.

I tried to change the code to :

If Len(Range("txtUser").Text) > 0 And Len(Range("txtPass").Text) > 0 Then

but the error become:

Run-time error '1004': Method 'Range' of object '_Global' failed

and then I tried to change and use variabe :
Dim txtUser as Range
Dim txtPass as Range

but the error become:

Run-time error '91': Object variable or With block variable not set

User name and password were in the same input box, with name: Userfomr1

What actually was wrong in this code? Please help... thank you
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top