From: puiuluipui on 25 May 2010 05:29 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!
From: Mike H on 25 May 2010 05:47 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!
From: puiuluipui on 25 May 2010 06:07 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!
From: Mike H on 25 May 2010 06:18 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!
From: Per Jessen on 25 May 2010 06:32 Hi This should do it: Sub Macro1() Set sht = Sheets("Sheet1") ' change to suit With sht If UCase(.Range("A1")) = "JOHN" _ And UCase(.Range("C1")) = "MARI" _ And .Range("D1") = "" Then msg = MsgBox("Macro 1", vbInformation, "Running") ElseIf UCase(.Range("A1")) = "JIM" _ And UCase(.Range("C1")) = "CRIS" _ And UCase(.Range("D1")) = "MONDAY" Then msg = MsgBox("Macro 2", vbInformation, "Running") Macro2 Else MsgBox "Criteria not met" Exit Sub End If End With 'Your code End Sub "puiuluipui" <puiuluipui(a)discussions.microsoft.com> skrev i meddelelsen news:8DB11995-E689-40E2-BDDC-1D587FA84E15(a)microsoft.com... > 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!
|
Next
|
Last
Pages: 1 2 3 Prev: automatically update the pivot table Next: Insert symbol as a header for a column |