gpt4 book ai didi

excel vba需要控制来检查是否有空单元格

转载 作者:行者123 更新时间:2023-12-02 22:00:12 25 4
gpt4 key购买 nike

    Private Function test()
Dim S1 As String, S2 As String

Dim lRow As Long, i As Long
Dim ws As Worksheet

Set ws = ActiveWorkbook.Sheets("pppdp")
With ws
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 19 To lRow
End Function

嗨,我有用于将表导出到xml的Excel工作表,所以我需要控制来检查A到R范围内是否有空单元格,我从这个开始,但我停在那里并且不'不知道下一步该做什么。

最佳答案

is there empty cell in range A to R?

逻辑是检查单元格总数是否等于填充的单元格总数。

像这样吗?

Sub Sample()
If test = False Then
MsgBox "Range A to R has empty cells"
Else
MsgBox "No Empty Cells"
End If
End Sub

Private Function test() As Boolean
Dim lRow As Long
Dim ws As Worksheet

Set ws = ActiveWorkbook.Sheets("pppdp")

With ws
If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
lRow = .Range("A:R").Find(What:="*", _
After:=.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Else
lRow = 1
End If

test = Application.WorksheetFunction.CountA(.Range("A1:R" & lRow)) _
= .Range("A1:R" & lRow).Cells.Count
End With
End Function

enter image description here

关于excel vba需要控制来检查是否有空单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21657740/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com