Related:

- Excel pop up message based on cell value
- Excel vba pop up message depending on cell value - Best answers
- Excel vba msgbox when cell meets criteria - Best answers
- Excel pop up message based on cell value without vba ✓ - Forum - Excel
- Excel macro insert picture based on cell value - Forum - Excel
- Excel vba insert rows based on cell value - Forum - Excel
- How To Insert Pictures in Excel Using a Macro - How-To - Excel
- Pop up message stating empty cells ✓ - Forum - Excel

## 2 replies

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

You have three sub routines with same name and signature It cannot be so. You need to do like this

Private Sub Worksheet_Calculate()

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

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

End If

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

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

End If

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

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

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

End If

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.