Msgbox Sheet 2 only when 2 conditions met in sheet 1

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hi

The below code creates a message box that runs every time Sheet 'Calculators' is activated.
VBA Code:
Private Sub Worksheet_Activate()

ActiveWindow.DisplayHeadings = False

Range("G26").Select
MsgBox "Enter temperature (ºF) from connect.garmin.com/modern", vbInformation, "Garmin.com Temperature (F) Conversion"
Application.Calculation = xlCalculationAutomatic
End Sub
I'd be grateful if the above code could be modified so it only runs when both of the below conditions are met:

1. Col A of the last row in sheet 'Training Log' contains today's date and
2. Col B of the same row in that sheet does not contain any of these text strings (within the commas): "OTHER (IB)", "OTHER (OB)", "OTHER (W)", "OTHER (T)", "REST", ""

Many thanks!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Do you really want the null string ("") in the list of text strings? A blank cell will meet the condition .Value = ""
 
Upvote 0
Hi Joe - thinking about it, yes you're quite right, forget that please, thanks for pointing that out.
 
Upvote 0
Try This:
VBA Code:
Private Sub Worksheet_Activate()
Dim Lrw As Long, Textstrs As Variant
Lrw = Sheets("Training Log").Cells(Rows.Count, "A").End(xlUp).Row
Textstrs = Array("OTHER (IB)", "OTHER (OB)", "OTHER (W)", "OTHER (T)", "REST")
With Sheets("Training Log")
    If .Cells(Lrw, "A").Value2 <> Date Then Exit Sub
    For i = LBound(Textstrs) To UBound(Textstrs)
        If .Cells(Lrw, "B").Value Like "*" & Textstrs(i) & "*" Then Exit Sub
    Next i
End With
ActiveWindow.DisplayHeadings = False
Range("G26").Select
MsgBox "Enter temperature (ºF) from connect.garmin.com/modern", vbInformation, "Garmin.com Temperature (F) Conversion"
Application.Calculation = xlCalculationAutomatic
End Sub
 
Upvote 0
Solution
That works perfectly! Thanks ever so much once again Joe!
 
Upvote 0

Forum statistics

Threads
1,214,818
Messages
6,121,725
Members
449,049
Latest member
MiguekHeka

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