Excel VBA需要控制,将检查是否是空的单元格

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 

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

范围A到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 

在这里输入图像说明