EXCEL VBA 判断A列空值 如果 A1:A30 单元格为空,则弹出对话框“空了”并说明有几个,位置在哪~
展开全部
你没写清楚是要查空单元格啊还是 查单元格内容有空格.汗一个先.两首镇段代码都贴给你吧
在工作表名称上点右键,选查看代码,粘贴下面的代码
Sub 检查空单元格()
Dim rng As Range, arr()
For Each rng In Range("A1:A30"扰盯)
If rng = "" Then
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = rng.Address(0, 0)
End If
Next
MsgBox "A1:A30有者李粗" & N & "个空单元格," & vbCrLf & "分别是:" & Join(arr, ",")
End Sub
Sub 检查空格()
Dim rng As Range, arr()
For Each rng In Range("A1:A30")
If InStr(rng, " ") <> 0 Then
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = rng.Address(0, 0)
End If
Next
MsgBox "A1:A30包含空格的单元格有" & N & "个," & vbCrLf & "分别是:" & Join(arr, ",")
End Sub
在工作表名称上点右键,选查看代码,粘贴下面的代码
Sub 检查空单元格()
Dim rng As Range, arr()
For Each rng In Range("A1:A30"扰盯)
If rng = "" Then
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = rng.Address(0, 0)
End If
Next
MsgBox "A1:A30有者李粗" & N & "个空单元格," & vbCrLf & "分别是:" & Join(arr, ",")
End Sub
Sub 检查空格()
Dim rng As Range, arr()
For Each rng In Range("A1:A30")
If InStr(rng, " ") <> 0 Then
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = rng.Address(0, 0)
End If
Next
MsgBox "A1:A30包含空格的单元格有" & N & "个," & vbCrLf & "分别是:" & Join(arr, ",")
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询