如何从工作表顶部开始的行偏移量开始

时间:2019-11-08 21:34:26

标签: excel vb.net

我正在尝试报告从第4行到文件结尾的A-F列中为空的单元格(前3行是标题信息)。这是我的过程。偏移量方法无效。另外,我该怎么打印列字母而不是列号(c.Column)

Public Function ValidateWSRows(ByRef ws As Worksheet) As Boolean

    ' Check for required data in cell columns A-F of Project Worksheet
    '
    Dim cellcount() As String
    Dim count As Integer = 0

    ws.Offset(rowOffset:=4).Activate
    For Each c In ws.Range("A:F").Cells
        If c.Value = "" Then
            cellcount(count) = c.Column + c.Row
            count = count + 1
        End If

        Console.WriteLine("The following Empty cells are not allowed in Columns A-F: ")
        Console.WriteLine(cellcount)

        If count > 0 Then
            ValidateWSRows = False
        Else
            ValidateWSRows = True
        End If

    Next

End Function

0 个答案:

没有答案
相关问题