VBA 03 IF Criteria Conditions

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,124
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I have 03 'IF' Criteria Conditions be satisfied that represent 03 Macros posted here:




Criteria 1 = Sheet1 (A1) & Sheet 10 (A1); are both BLANK and produce:
MsgBox ("First Enter DATE!!")

Code:
Sub Macro36()
'
' Macro36 Macro
'
'
        If IsEmpty(Sheet1.Range("A1").Value) Then
        
        If IsEmpty(Sheet10.Range("A1").Value) Then
        
        MsgBox ("First Enter DATE!!")
    
    End If
    End If
     
 Exit Sub
 
 
End Sub

Criteria 2 = Sheet1 (A1) & Sheet 10 (A1); where Sheet1 has a # in A1 AND Sheet10 A1 is BLANK and produces: MsgBox ("Continue Sub!!")


Code:
Sub Macro37()
'
' Macro36 Macro
'
'
        If Not IsEmpty(Sheet1.Range("A1").Value) Then
        
        If IsEmpty(Sheet10.Range("A1").Value) Then
        
        MsgBox ("Continue Sub!!")
    
    
    End If
    End If
     
 Exit Sub
 
 
End Sub


Criteria 3 = Sheet1 (A1) & Sheet 10 (A1); where Sheet1 has a # in A1 AND Sheet10 A1 has a # and produces: MsgBox ("This was already Executed!!")

Code:
Sub Macro38()
'
' Macro36 Macro
'
'
        If Not IsEmpty(Sheet1.Range("A1").Value) Then
        
        If Not IsEmpty(Sheet10.Range("A1").Value) Then
        
        MsgBox ("This was already Executed!!")
    
    
    End If
    End If
     
 Exit Sub
 
 
End Sub


My conundrum is, how do I combine these 03 Macros into a single Macro??


I've tried several methods and I'm not getting it.

Please post a code to help, if you can.

Thank you!

-Pin
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
One way:

Code:
Sub MacroP()
  If IsEmpty(Sheet1.Range("A1").Value) Then
    If IsEmpty(Sheet10.Range("A1").Value) Then
      MsgBox "First Enter DATE!!"
    End If
  ElseIf IsEmpty(Sheet10.Range("A1").Value) Then
    MsgBox "Continue Sub!!"
  Else
    MsgBox "This was already Executed!!"
  End If
End Sub
 
Last edited:
Upvote 0
I think this would work:

Code:
Sub Macro39()
  If IsEmpty(Sheet10.Range("A1").Value) Then
    If IsEmpty(Sheet1.Range("A1").Value) Then
      MsgBox "First Enter DATE!!"
    Else
      MsgBox "Continue Sub!!"
    End If
  Else
    MsgBox "This was already Executed!!"
  End If
End Sub
 
Upvote 0
Hello,

Your codes that you provided is working out nicely, thanks again!

I have something to add, that I think warrants this continued string? Please inform, if on the contrary to this based on the below, as this is really confusing for me:


The;
Code:
Sub Macro39()
  If IsEmpty(Sheet10.Range("A1").Value) Then
    If IsEmpty(Sheet1.Range("A1").Value) Then
      MsgBox "First!!"
    Else
      MsgBox "Second!!"
    End If
  Else
    MsgBox "This was already Executed!!"
  End If
End Sub

Works for
MsgBox "First!!
if cells of Sheet 10. A1 & Sheet 1. A1 are empty.


MsgBox "Second!!
works if cell Sheet 1. A1 is not empty & Sheet 10. A1 is empty.

How would I add an additional criteria of for example;
If cells of Sheet 1. A1 & Sheet10.A1 & Sheet5.A1 have a value then MsgBox "Third!!"

I've been trying to wrap my head around this and it seems the simple is complex and vice versa.

Can someone please help me to put this criteria into the
Code:
Sub Macro39()
??


Thanks,

Pinaceous
 
Upvote 0
Hi All,

I've reviewed the code and came up with this for my solution.

It works fine.

Thanks!



Code:
Sub Macro39()
Dim response As VbMsgBoxResult
     If Not IsEmpty(Sheet5.Range("A1").Value) Then
    MsgBox "THIRD!!"
        Exit Sub
      End If
      
  If IsEmpty(Sheet10.Range("A1").Value) Then
    If IsEmpty(Sheet1.Range("A1").Value) Then
      MsgBox "FIRST!!"
        Exit Sub
    Else
      MsgBox "SECOND!!"
        Exit Sub
    End If
  Else
  response = MsgBox("PASSED CRITERIA??", vbYesNo)
    If response = vbNo Then
    MsgBox "START AGAIN"
  Exit Sub
        End If
        
  End If
  
    
    MsgBox "HELP!!"
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,358
Messages
6,171,625
Members
452,412
Latest member
thomasleysen531

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top