Conditional Message Box

L

LaDdIe

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
 
J

JE McGimpsey

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
 
C

Chergh

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top