Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default object variable or with block not set


This is what I currently have, however if my entry is not in the range
then it makes me debug saying object variable not set or with block not
set. Is there anyway that I can actually have a msgbox "Not found" pop
up if the entry entered is not in the list.


Range("A1:A500").Select
Dim EmailAddress As String
EmailAddress = InputBox("enter Email Address", "Email Address")
Selection.Find(What:=EmailAddress, After:=ActiveCell,
LookIn:=xlFormulas, _
Lookat:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext,
_
MatchCase:=False, searchformat:=False).Activate


Thanks for any help


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=521150

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default object variable or with block not set

Dim Found as Range
.....
set Found = Selection.Find(...)
if found is Nothing then msgbox "not found"


HTH
--
AP

"jhahes" a écrit dans
le message de ...

This is what I currently have, however if my entry is not in the range
then it makes me debug saying object variable not set or with block not
set. Is there anyway that I can actually have a msgbox "Not found" pop
up if the entry entered is not in the list.


Range("A1:A500").Select
Dim EmailAddress As String
EmailAddress = InputBox("enter Email Address", "Email Address")
Selection.Find(What:=EmailAddress, After:=ActiveCell,
LookIn:=xlFormulas, _
Lookat:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext,
_
MatchCase:=False, searchformat:=False).Activate


Thanks for any help


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:

http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=521150



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default object variable or with block not set


I tried the solution and got the same error both times now. When I
found the entry and when I didn't find the entry.


Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=521150

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default object variable or with block not set

This works by me:

'------------------------------
Sub test()
Dim EmailAddress As String
Dim found As Range
Range("A1:A500").Select
EmailAddress = InputBox( _
"enter Email Address", _
"Email Address")
Set found = Selection.Find( _
What:=EmailAddress, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
Lookat:=xlPart, _
Searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)
If found Is Nothing Then
MsgBox "Not found"
Else
found.Activate
End If
End Sub
--

HTH
--
AP

"jhahes" a écrit dans
le message de ...

I tried the solution and got the same error both times now. When I
found the entry and when I didn't find the entry.


Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:

http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=521150



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 '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
Getting inconsistent Error 91-Object variable or With block variable not set mfq Excel Programming 0 December 14th 05 06:08 PM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM
Pivot Table - Object variable or with block variable not set? George Nicholson[_2_] Excel Programming 1 April 16th 04 09:12 PM


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

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

About Us

"It's about Microsoft Excel"