Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default If a value exists in a range

I am trying to have VBA evaluate the range C3:C100 (name defined as
Type_of_change), and if the value "TEST" exists in any one of those cells,
call Macro A, if not, Call Macro B. How do I get VBA to evaluate the range?

Thanks
Jeff

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default If a value exists in a range

Sub jeffbert()
Set r = Range("C3:C10")
wellisit = False
For Each rr In r
If InStr(rr.Value, "TEST") 0 Then
wellisit = True
Else
End If
Next
If wellisit Then
Call macroa
Else
Call macrob
End If
End Sub
--
Gary''s Student
gsnu200705


"jeffbert" wrote:

I am trying to have VBA evaluate the range C3:C100 (name defined as
Type_of_change), and if the value "TEST" exists in any one of those cells,
call Macro A, if not, Call Macro B. How do I get VBA to evaluate the range?

Thanks
Jeff

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default If a value exists in a range

if application.Countif(Range("C3:C100"),"Test") 0 then
MacroA
else
MacroB
End if

if test is not the sole value of the cell then

if application.Countif(Range("C3:C100"),"*Test*") 0 then
MacroA
else
MacroB
End if

--
Regards,
Tom Ogilvy


"jeffbert" wrote in message
...
I am trying to have VBA evaluate the range C3:C100 (name defined as
Type_of_change), and if the value "TEST" exists in any one of those cells,
call Macro A, if not, Call Macro B. How do I get VBA to evaluate the
range?

Thanks
Jeff



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
how to lookup if value exists in a range of data? S.elhalaby Excel Worksheet Functions 3 May 5th 23 07:43 PM
See if a Range Name exists? plh Excel Programming 3 April 30th 06 10:12 PM
Check if named range exists! steve_doc Excel Programming 2 April 29th 06 11:56 PM
Validate Named Range Exists John Jost Excel Programming 5 December 5th 05 08:17 PM
how to tell if a named range exists Gixxer_J_97[_2_] Excel Programming 2 June 1st 05 07:38 PM


All times are GMT +1. The time now is 10:40 AM.

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"