Thread
:
MsgBox if within selected rows a specific column is not filled in
View Single Post
#
2
Posted to microsoft.public.excel.programming
Claus Busch
external usenet poster
Posts: 3,872
MsgBox if within selected rows a specific column is not filled in
Hi Johan,
Am Fri, 25 Nov 2016 12:33:56 -0800 (PST) schrieb
:
In a sheet several rows are selected. It could be rows near eachother (like row 5 till 15) or even rows that are not near eachother (like row 5 till 15 and also row 25 till 30). It could be also only one or two separated rows.
I have a macro that do some follow up actions with those selected rows, but in in those selected rows in column K there must be data filled in in each row of it.
If in one of them the datafield in column K is empty, I want a MsgBox which shows me the number of empty datafields in column K.
try:
Sub Test()
Dim rngC As Range
Dim varEmpty() As Variant
Dim n As Long, i As Long
Dim myStr As String
For Each rngC In Intersect(Range("K:K"), Selection)
If Len(rngC) = 0 Then
i = i + 1
ReDim Preserve varEmpty(n)
varEmpty(n) = rngC.Address(0, 0)
n = n + 1
End If
Next
myStr = Join(varEmpty, Chr(10))
MsgBox "These " & i & " cells are empty:" & Chr(10) & myStr
End Sub
Regards
Claus B.
--
Windows10
Office 2016
Reply With Quote
Claus Busch
View Public Profile
Find all posts by Claus Busch