Help If cell contains certain text run macro if not message box

1nk3d

Board Regular
Joined
May 31, 2016
Messages
51
I have a macro for a workbook, I will post the beginning of the code below. We have a selection sheet (Home) What I need is for if cell G9 on Home says select, a message box to pop up and end, if G9 contains any other text, resume the macro below.

Code:
Sub PWSub()
    If (Now() - Int(Now()) < TimeValue("6:30:00")) Then
        MsgBox "You are attempting to pull the data too early.  Data is not available until after 6:30"
        ElseIf (Now() - Int(Now()) > TimeValue("19:30:00")) Then
        MsgBox "Data needs to be pulled before 11:00 AM daily. Try again tomorrow"
    Else
        OpenPrevWeek
    End If
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Code:
Sub PWSub2()
    If LCase(Sheets("Home").Range("G9").Text) = "select" Then
        MsgBox "Procedure will now terminate."
        Exit Sub
    ElseIf Sheets("Home").Range("G9") <> "" Then
        If (Now() - Int(Now()) < TimeValue("6:30:00")) Then
            MsgBox "You are attempting to pull the data too early.  Data is not available until after 6:30"
        ElseIf (Now() - Int(Now()) > TimeValue("19:30:00")) Then
            MsgBox "Data needs to be pulled before 11:00 AM daily. Try again tomorrow"
        Else
            OpenPrevWeek
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,716
Members
449,093
Latest member
Mnur

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