PDA

View Full Version : Count Empty Range and MsgBox



MrYemin09
11-13-2009, 09:57 AM
Hi ,please help me this asking!
I want to know VBA codes for count Empty Range of only Sum Row and how to show MsgBox Empty Range Name ,if "=SUM" ActiveRow. I want know that following picture. please replay say me .
Very Thanks!

http://i36.tinypic.com/i59fgn.jpg (http://www.vbaexpress.com/forum/%5BIMG%5Dhttp://i36.tinypic.com/i59fgn.jpg%5B/IMG%5D)

Bob Phillips
11-13-2009, 12:12 PM
For Each cell In Range("B2:M2")

If cell.Value = "" then

tmp = tmp & cell.Value & vbnewline
End If
Next cell

If tmp <> "" Then

MsgBox tmp
End If

mdmackillop
11-13-2009, 04:48 PM
My understanding of your request

Sub BlankMonths()
Dim cel As Range, txt As String
For Each cel In Cells(ActiveCell.Row, 2).Resize(, 12)
If cel = "" Then
txt = txt & Cells(1, cel.Column) & vbCr
End If
Next
MsgBox txt
End Sub

Bob Phillips
11-13-2009, 05:10 PM
As mdmackillop has pointed out to me, I forgot to offset my code.

It should be



Dim cell As Range
Dim tmp As String

For Each cell In Range("B2:M2")

If cell.Value = "" Then

tmp = tmp & cell.Offset(-1, 0).Value2 & vbNewLine
End If
Next cell

If tmp <> "" Then

MsgBox tmp
End If

MrYemin09
11-14-2009, 06:46 AM
Very good Answer ! Very Thanks for all !
Please say me ,how to study VBA excel From Basic ?