problem with this code

T

Travis

When I run the following code I am getting the error 1004

"Method 'Range' of object '_Global' failed"
 
T

Tom Ogilvy

Looks like I had a typo in Range(A65536). should have been Range("A65536")

Private Sub TextBox1_AfterUpdate()
Dim rng As Range
With Worksheets("Sheet1").Columns(1)
Set rng = .Find(what:=UserForm1.TextBox1.Text, _
After:=Range("A65536"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
If Not rng Is Nothing Then
With UserForm1
.TextBox2.Text = rng.Offset(0, 1).Value
.TextBox3.Text = rng.Offset(0, 2).Value
' and so forth
End With
Else
MsgBox UserForm1.TextBox1.Text & _
" was not found"
End If

End Sub

worked fine for me.
 

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