LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default If column contains a value - Error Trap

There are a few ways you can structure this depending on what you want to
happen after the error message is displayed, but the following should get
you started...

If Not Columns("A").Find("Test", LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False) Is Nothing Then
MsgBox "Here is your error message"
Else
MsgBox "Put your working code in here."
End If

The key is to perform the "Not...Is Nothing" test on the result of
attempting to Find the text you are looking for in the specified range for
the Find method.

--
Rick (MVP - Excel)


"Louise" wrote in message
...
Hi,

I am trying to apply some error trapping to my code now.

I want to say that if a value (e.g. "Test") does not appear in Column A
then
carry on, otherwise if it does appear in Column A (on any row) then an
error
message pops up.

Can this be done, and how?

Thanks,


 
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
Set Error handling INSIDE error-trap Michelle Excel Programming 6 May 3rd 08 03:30 PM
Need error trap GregR Excel Programming 4 June 14th 07 08:28 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error Trap Kirk P. Excel Programming 2 September 8th 05 09:51 PM


All times are GMT +1. The time now is 03:22 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"