Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Runtime error textbox problem - help required

Hello everyone

I am entering text into a textbox then trying to run code adapted from
"Find" to locate a cell on the worksheet.

I get a runtime error 424 - Object required but as I have limited knowledge
I dont know why!

When I debug if I hover the curser over the highlighted row the correct text
from the textbox is shown but if I hover over MyFind in the next row the
value is empty.

Could anyone tell me what is required?
Here is the code I am using

Sub MyFind()
'
' MyFind Macro
' Macro recorded 19/10/2004 by Kenny
'
Dim MyFind As Range
Set MyFind = UserForm1.TextBox2.Value xxxxxxxxxxxxxxxxxx this is
the problem row
'
Cells.Find(What:=MyFind, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Runtime error textbox problem - help required

Try:

Dim MyFind as Variant
MyFind = UserForm1.TextBox2.Value
' the rest of your code

As it is a text box you can probably also use:

Dim MyFind as String which is more efficient in memory (but no big deal
here)

And I would suggest you call the subroutine something different to the
variable, for example, MyFindSub

Regards

Trevor


"N E Body" wrote in message
...
Hello everyone

I am entering text into a textbox then trying to run code adapted from
"Find" to locate a cell on the worksheet.

I get a runtime error 424 - Object required but as I have limited
knowledge
I dont know why!

When I debug if I hover the curser over the highlighted row the correct
text
from the textbox is shown but if I hover over MyFind in the next row the
value is empty.

Could anyone tell me what is required?
Here is the code I am using

Sub MyFind()
'
' MyFind Macro
' Macro recorded 19/10/2004 by Kenny
'
Dim MyFind As Range
Set MyFind = UserForm1.TextBox2.Value xxxxxxxxxxxxxxxxxx this is
the problem row
'
Cells.Find(What:=MyFind, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Runtime error textbox problem - help required

Thanks Trevor - that did the trick!

Kenny
"Trevor Shuttleworth" wrote in message
...
Try:

Dim MyFind as Variant
MyFind = UserForm1.TextBox2.Value
' the rest of your code

As it is a text box you can probably also use:

Dim MyFind as String which is more efficient in memory (but no big deal
here)

And I would suggest you call the subroutine something different to the
variable, for example, MyFindSub

Regards

Trevor


"N E Body" wrote in message
...
Hello everyone

I am entering text into a textbox then trying to run code adapted from
"Find" to locate a cell on the worksheet.

I get a runtime error 424 - Object required but as I have limited
knowledge
I dont know why!

When I debug if I hover the curser over the highlighted row the correct
text
from the textbox is shown but if I hover over MyFind in the next row the
value is empty.

Could anyone tell me what is required?
Here is the code I am using

Sub MyFind()
'
' MyFind Macro
' Macro recorded 19/10/2004 by Kenny
'
Dim MyFind As Range
Set MyFind = UserForm1.TextBox2.Value xxxxxxxxxxxxxxxxxx this

is
the problem row
'
Cells.Find(What:=MyFind, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,

_
MatchCase:=False).Activate
End Sub






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Runtime error textbox problem - help required

Hi.
Data type problem (below)

"N E Body" skrev i melding
...
Dim MyFind As Range
Set MyFind = UserForm1.TextBox2.Value xxxxxxxxxxxxxxxxxx this is
the problem row


Range is an object of one or more cells. What's in your textbox is probably
what you want to search for, which is a text, string, and not a range:

Dim MyFind As String
MyFind = UserForm1.TextBox2.Text

Cells.Find(What:=MyFind, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

(Now MyFind is a bad name. I think you may have been confusing the search
criteria and the search result, which surely is a range. Those are two
different beasts.)

HTH. Best wishes Harald


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
Runtime error '424': Object Required loren.pottinger Excel Discussion (Misc queries) 1 August 28th 06 09:56 PM
"Microsoft Visual Basic runtime error '424' object required". SharonG. Excel Worksheet Functions 0 July 5th 06 01:36 AM
Runtime error only with Office 97 - advice required Kennyatwork Excel Programming 2 May 12th 04 02:11 AM
runtime error ....object required mlm Excel Programming 3 February 18th 04 06:09 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 04:35 AM.

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"