Run macro only if
Hi, i cant make it work. The first one was simplier. I tried to copy the
first macro twice, but it doesn't work this way.
This new macro with concatenate it's more complicated. I can't make it work.
I had JOHN in A1 and MARI in C1. In D1 i had nothing. And it doesn't work.
What am i doing wrong?
Thanks!
"Mike H" a scris:
Hi,
You could concatenate the 3 cell into one string and decide which sub to
call using select case
Sub anothersub()
Set sht = Sheets("Sheet1") ' change to suit
With sht
mynames = .Range("A1") & .Range("C1") & .Range("D1")
End With
mynames = UCase(mynames)
Select Case mynames
Case "JOHNMARI"
Call thissub
Case "PETEJOE"
Call thatsub
Case "MIKEPUIULUIPUI"
Call theothersub
Case Else
MsgBox "Criteria not met"
End Select
End Sub
--
Mike
When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
"puiuluipui" wrote:
Hi, it's perfect!
But i have one more question. Can this macro be made to run another macro if
in A1 and C1 is another names?
EX:
A1 = John
C1 = Mari
D1 = "empty"
If this criteria is met, then the macro to run MACRO 1
If in this cells i have:
A1 = Jim
C1 = Cris
D1 = Monday
and the macro to run MACRO 2.
and if it's possible, the message box, to display the name of the macro that
it's running (MACRO 1 or MACRO 2)
Can this be done?
Thanks!!!
"Mike H" a scris:
Hi,
Is this what you mean
Sub somemacro()
Set sht = Sheets("Sheet1") ' change to suit
With sht
If UCase(.Range("A1")) < "JOHN" _
Or UCase(.Range("C1")) < "MARI" _
Or .Range("D1") < "" Then
MsgBox "Criteria not met"
Exit Sub
End If
End With
'Your code
End Sub
--
Mike
When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
"puiuluipui" wrote:
Hi, i need a macro to run if A1 contains "John" and C1 contains "Mari", and
if D1 is blank. If this criteria is not mached, then the macro to display a
message.
Can this be done?
Thanks!
|