Related:

- Excel pop up message based on cell value
- Excel vba pop up message depending on cell value - Best answers
- Display message box based on cell value - Best answers
- Excel macro insert picture based on cell value - Forum - Excel
- Excel create new tab based on cell value - How-To - Excel
- Pop up message stating empty cells ✓ - Forum - Excel
- Excel vba filter column based on cell value ✓ - Forum - Excel
- Adding a loop to macro to insert pictures ✓ - Forum - Excel

Helper

This code assumes that what you are looking for is in column A.

Private Sub Find_Criteria()

Dim i

Dim r

r = Range("A65536").End(xlUp).Row

i = 1

For I = I To r

If Range("A" & i) = "criteria" Then

MsgBox "Found" & " " & Range("A" & i).Address

End If

Next i

End Sub

If you are looking for certain criteria in a range of cells, then try something like this.

Private Sub Find_Criteria()

Dim I As Variant

Dim FindRange As Range

Set FindRange = Range("A1:K50")

For Each I In FindRange

If I = "criteria" Then

MsgBox "Found" & " " & i.Address

End If

Next i

End Sub

Private Sub Find_Criteria()

Dim i

Dim r

r = Range("A65536").End(xlUp).Row

i = 1

For I = I To r

If Range("A" & i) = "criteria" Then

MsgBox "Found" & " " & Range("A" & i).Address

End If

Next i

End Sub

If you are looking for certain criteria in a range of cells, then try something like this.

Private Sub Find_Criteria()

Dim I As Variant

Dim FindRange As Range

Set FindRange = Range("A1:K50")

For Each I In FindRange

If I = "criteria" Then

MsgBox "Found" & " " & i.Address

End If

Next i

End Sub

cx72go

I can not get this code to work, I am getting an ambiguos error I do need all 3 message boxes to come up at the same time if the < value is met. Thanks any help is appreciated

Private Sub Worksheet_Calculate()

If Range("F10").Value < 5300 Then

MsgBox "Initial Load Must be at least 5,300Kgs"

End If

End Sub

Private Sub Worksheet_Calculate()

If Range("G10").Value < 4300 Then

MsgBox "Initial Load Must be at least 4,300Kgs"

End If

End Sub

Private Sub Worksheet_Calculate()

If Range("H10").Value < 1300 Then

MsgBox "Initial Load Must be at least 1,300Kgs"

End If

End Sub

Private Sub Worksheet_Calculate()

If Range("F10").Value < 5300 Then

MsgBox "Initial Load Must be at least 5,300Kgs"

End If

End Sub

Private Sub Worksheet_Calculate()

If Range("G10").Value < 4300 Then

MsgBox "Initial Load Must be at least 4,300Kgs"

End If

End Sub

Private Sub Worksheet_Calculate()

If Range("H10").Value < 1300 Then

MsgBox "Initial Load Must be at least 1,300Kgs"

End If

End Sub

rizvisa1

- Posts
- 4476
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- August 2, 2020

Not know exactly why message boxes are needed. But in case you can live with one message box that have all possible errors, you can try this

Private Sub Worksheet_Calculate() Dim myMessage As String myMessage = "" If Range("F10").Value < 5300 Then If (myMessage <> "") Then myMessage = myMessage & vbCrLf myMessage = myMessage & "Initial Load Must be at least 5,300Kgs" End If If Range("G10").Value < 4300 Then If (myMessage <> "") Then myMessage = myMessage & vbCrLf myMessage = myMessage & "Initial Load Must be at least 4,300Kgs" End If If Range("H10").Value < 1300 Then If (myMessage <> "") Then myMessage = myMessage & vbCrLf myMessage = myMessage & "Initial Load Must be at least 1,300Kgs" End If If (myMessage <> "") Then MsgBox (myMessage) End Sub

cx72go
>
rizvisa1

- Posts
- 4476
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- August 2, 2020

I am trying to tell a lab person when there is not enough product in a vessel to hit the agitator blades at the same time I am trying to remind him how much he does need. I first tried to make an adjacent cell highlight and appear with the correct value using conditional formatting but I was unable to get that to work so I tried vba.

Thanks jerry

Thanks jerry

rizvisa1

- Posts
- 4476
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- August 2, 2020

Jerry I meant there are three messages. So potentially three time ok needs to be clicked. There can also be one message with all the warnings listed. Thats what I tried to show in the macro in message #5. I thought it may be of interest to you. Of course there might be cases, where every warning needs to come up one by one and this might be one of those case.

cx72go
>
rizvisa1

- Posts
- 4476
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- August 2, 2020

i dd like the one message box better I wish I had your talent at this stuff, I have two sections that need these reminder messages on the same page, is there a way to kkeep them seperate? this is what I have now:

Private Sub Worksheet_Calculate()

Dim myMessage As String

myMessage = ""

If Range("F10").Value < 5300 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 5,300Kgs for R-5"

End If

If Range("G10").Value < 4300 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 4,300Kgs for R-4"

End If

If Range("H10").Value < 1300 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 1,300Kgs for R-3 "

End If

If Range("H10").Value < 3000 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 3,000Kgs for R-2 "

End If

If Range("F22,G22").Value < 1450 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 1,450Kgs for #4 & 5 Premix"

End If

If Range("H22").Value < 1675 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 1,675Kgs for #3 Premix"

End If

If Range("I22").Value < 905 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 905Kgs for #2 Premix"

End If

If (myMessage <> "") Then MsgBox (myMessage)

End Sub

Private Sub Worksheet_Calculate()

Dim myMessage As String

myMessage = ""

If Range("F10").Value < 5300 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 5,300Kgs for R-5"

End If

If Range("G10").Value < 4300 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 4,300Kgs for R-4"

End If

If Range("H10").Value < 1300 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 1,300Kgs for R-3 "

End If

If Range("H10").Value < 3000 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 3,000Kgs for R-2 "

End If

If Range("F22,G22").Value < 1450 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 1,450Kgs for #4 & 5 Premix"

End If

If Range("H22").Value < 1675 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 1,675Kgs for #3 Premix"

End If

If Range("I22").Value < 905 Then

If (myMessage <> "") Then myMessage = myMessage & vbCrLf

myMessage = myMessage & "Initial Load Must be at least 905Kgs for #2 Premix"

End If

If (myMessage <> "") Then MsgBox (myMessage)

End Sub

rizvisa1

- Posts
- 4476
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- August 2, 2020

First, I am not sure if this is correct

**If Range("F22,G22").Value < 1450 Then **

you can have it like this

If ( (Range("F22") < 1450) AND (Range("G22") < 1450) ) Then

or

If ( (Range("F22") < 1450) OR (Range("G22") < 1450) ) Then

depending what you want.

From what I understood, you want two set of possible warnings, with in this one routine. You can do that

so after first msgbox pops up ( If (**myMessage <> "") Then MsgBox (myMessage) **)

after that line

write

myMessage =""

This will reset the message to a blank string. And then you can again start adding the if statements as before and then finally again the code for msgbox to pop up, once done with "IFs"

you can have it like this

If ( (Range("F22") < 1450) AND (Range("G22") < 1450) ) Then

or

If ( (Range("F22") < 1450) OR (Range("G22") < 1450) ) Then

depending what you want.

From what I understood, you want two set of possible warnings, with in this one routine. You can do that

so after first msgbox pops up ( If (

after that line

write

myMessage =""

This will reset the message to a blank string. And then you can again start adding the if statements as before and then finally again the code for msgbox to pop up, once done with "IFs"