Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Excel and VBA - If and Find Expressions

Hello

I am trying to use an If statement to find an piece of text and then go to
the cell that contains that text. I have, as part of the if statement, an
else statement that just cancels the expression and does something else if it
cant find the iece of text. However, the expression doesnt seem to work when
VB cant find any cell with the specific text and it just comes back with a
run time error. Does anyone know if there is a proper way of putting a "find"
expression inside an "if" expression or maybe a better way of doing what I am
trying to do?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Excel and VBA - If and Find Expressions

One way

Sub findit()
Set myRange = Range("A1:C20") 'Change to suit
For Each c In myRange
If c.Value = "myvalue" Then
c.Select
found = True
End If
Next
If found = False Then MsgBox ("myvalue" & " Not found")
End Sub

Mike

"Ronan" wrote:

Hello

I am trying to use an If statement to find an piece of text and then go to
the cell that contains that text. I have, as part of the if statement, an
else statement that just cancels the expression and does something else if it
cant find the iece of text. However, the expression doesnt seem to work when
VB cant find any cell with the specific text and it just comes back with a
run time error. Does anyone know if there is a proper way of putting a "find"
expression inside an "if" expression or maybe a better way of doing what I am
trying to do?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Excel and VBA - If and Find Expressions

Post the code.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Ronan" wrote in message
...
Hello

I am trying to use an If statement to find an piece of text and then go to
the cell that contains that text. I have, as part of the if statement, an
else statement that just cancels the expression and does something else if
it
cant find the iece of text. However, the expression doesnt seem to work
when
VB cant find any cell with the specific text and it just comes back with a
run time error. Does anyone know if there is a proper way of putting a
"find"
expression inside an "if" expression or maybe a better way of doing what I
am
trying to do?



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
Where can I find the syntax and semantics for expressions in Excel 2003 headers and footers? Mark F[_2_] New Users to Excel 1 June 2nd 09 03:45 PM
excel asp and expressions web Healing Excel Discussion (Misc queries) 0 December 7th 07 05:11 PM
.CodeModule.Find AND PatternSearch (using Regular Expressions) Paul Martin Excel Programming 3 June 1st 06 07:32 AM
Regular expressions in Excel vigi98 Excel Discussion (Misc queries) 3 November 10th 05 04:40 PM
Regular expressions in Excel? a Excel Programming 8 March 4th 05 05:29 AM


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