Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default Macro if criteria

Hi, i have two macros. (macro 1 and macro 2)
I need macro 1 to run if in A1 is "JOHN", in B1 is "MARY" and if C1 is empty
; and macro 2 to run if in A1 is "JIM", in B1 is "CRIS" and in C1 is "BOB".
Can this be done?
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Macro if criteria

Seems simple

If Range("A1").Value2 = "JOHN" And _
Range("B1").Value2 = "MARY" And _
Range("C1").Value2 = "" Then
Call Macro1
ElseRange("A1").Value2 = "JIM" And _
Range("B1").Value2 = "CRIS" And _
Range("C1").Value2 = "BOB" Then
Call Macro2
End If

--

HTH

Bob

"puiuluipui" wrote in message
...
Hi, i have two macros. (macro 1 and macro 2)
I need macro 1 to run if in A1 is "JOHN", in B1 is "MARY" and if C1 is
empty
; and macro 2 to run if in A1 is "JIM", in B1 is "CRIS" and in C1 is
"BOB".
Can this be done?
Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Macro if criteria

Put this behind your sheet:
Private Sub Worksheet_Change(ByVal Target As Range)
'If Target.Cells.Count 3 Then Exit Sub
If Application.Intersect(Range("A1"), Target) Is Nothing Then
If Not IsNumeric(Target.Value) And Range("A1").Value = "JIM" And
Range("B1").Value = "CHRIS" And Range("C1").Value = "BOB" Then
Call Macro2
End If

If Not IsNumeric(Target.Value) And Range("A1").Value = "JOHN"
And Range("B1").Value = "MARY" And Range("C1").Value = "" Then
Call Macro1
End If

End If
End Sub


Put this in a Module:
Sub Macro1()
'Display MessageBox
Answer = MsgBox("Macro1")

End Sub

Sub Macro2()
'Display MessageBox
Answer = MsgBox("Macro2")

End Sub



--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"puiuluipui" wrote:

Hi, i have two macros. (macro 1 and macro 2)
I need macro 1 to run if in A1 is "JOHN", in B1 is "MARY" and if C1 is empty
; and macro 2 to run if in A1 is "JIM", in B1 is "CRIS" and in C1 is "BOB".
Can this be done?
Thanks!

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
macro criteria copy puiuluipui Excel Discussion (Misc queries) 9 December 1st 08 12:53 PM
check criteria and run macro pswanie Excel Programming 1 December 30th 07 12:57 PM
Msg Box to change Macro criteria? John Excel Programming 1 July 18th 05 03:55 PM
running a macro only if criteria are met The Grinch[_2_] Excel Programming 1 June 16th 04 03:28 PM
Criteria Macro pauluk[_11_] Excel Programming 1 March 3rd 04 05:49 PM


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