Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default problem with this code

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

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

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default problem with this code

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.

--

Regards,
Tom Ogilvy

"Travis" wrote in message
...
When I run the following code I am getting the error 1004

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

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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alt Code Problem aftamath77 Excel Discussion (Misc queries) 2 February 10th 09 11:42 PM
Problem with code kk Excel Discussion (Misc queries) 0 March 15th 08 03:01 PM
VB Code Problem Stan Excel Discussion (Misc queries) 6 April 25th 07 01:48 AM
problem with code gareth Excel Programming 1 December 5th 03 03:24 PM
Code Problem ! Mike R Excel Programming 5 August 5th 03 03:35 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"