ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Message Box (https://www.excelbanter.com/excel-programming/389772-conditional-message-box.html)

LaDdIe

Conditional Message Box
 
Hiya,

Can anyone tell me how to do the following

If A1 is Blank and D1 or E1 is greater than 0,

Then a message box to pop up requesting a value (text or number) in A1, the
message box to keep appearing until A1 has a value.

This needs to be repeated to A44.

Thanks for any help

Respectx

Laddie

JE McGimpsey

Conditional Message Box
 
One way:

Put this in your worksheet code module:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const csFILLRANGE As String = "A1:A44"
Dim vResult As Variant
Dim rBlanks As Range
Dim rCell As Range
On Error Resume Next
Set rBlanks = Range(csFILLRANGE).SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If Not rBlanks Is Nothing Then
For Each rCell In rBlanks
With rCell
If .Offset(0, 3).Value 0 Or .Offset(0, 4).Value 0 Then
Do
vResult = Application.InputBox( _
Prompt:="Enter a value for " & _
.Address(False, False) & ":", _
Title:="Fill " & csFILLRANGE, _
Default:=vbNullString, _
Type:=1 + 2)
If vResult = False Then vResult = vbNullString
Loop Until vResult < vbNullString
End If
Application.EnableEvents = False
.Value = vResult
Application.EnableEvents = True
End With
Next rCell
End If
End Sub

In article ,
LaDdIe wrote:

Hiya,

Can anyone tell me how to do the following

If A1 is Blank and D1 or E1 is greater than 0,

Then a message box to pop up requesting a value (text or number) in A1, the
message box to keep appearing until A1 has a value.

This needs to be repeated to A44.

Thanks for any help

Respectx

Laddie


Chergh

Conditional Message Box
 
Something like this should do it

for i = 1 to 44

if isempty(cells(i, 1) then

if cells(i,4) <= 0 then
msgbox("please put in a value"
end if

if cells(i,5) <=0 then
msgbox ("please put in a value")
end if

end if

next i

"LaDdIe" wrote:

Hiya,

Can anyone tell me how to do the following

If A1 is Blank and D1 or E1 is greater than 0,

Then a message box to pop up requesting a value (text or number) in A1, the
message box to keep appearing until A1 has a value.

This needs to be repeated to A44.

Thanks for any help

Respectx

Laddie


LaDdIe

Conditional Message Box
 
Thanks Fellas.

"LaDdIe" wrote:

Hiya,

Can anyone tell me how to do the following

If A1 is Blank and D1 or E1 is greater than 0,

Then a message box to pop up requesting a value (text or number) in A1, the
message box to keep appearing until A1 has a value.

This needs to be repeated to A44.

Thanks for any help

Respectx

Laddie



All times are GMT +1. The time now is 10:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com