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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,130,119
Messages
5,640,226
Members
417,130
Latest member
Seanr19871

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
Top