0

I'm trying to report cells that are empty in columns A-F starting at row 4 to end of file (top 3 rows are title information).. Here is my procedure. The offset method is not valid. Also, how to do I print the column letter and not the column number (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
BruceWayne
  • 22,923
  • 15
  • 65
  • 110
C C
  • 1
  • 4
  • 1
    FYI - You will almost positively want to restrict your range. Currently, you're checking *every single cell* in columns A:F....That's going to take a long while. I'd [get the last row](https://stackoverflow.com/questions/38882321/better-way-to-find-last-used-row) of your data, then do say `For each c in ws.Range("A4:F" & lastRow).Cells ...`. – BruceWayne Nov 08 '19 at 21:36
  • `c.Address(False, False)` should give you the address of a cell – cybernetic.nomad Nov 08 '19 at 21:47
  • Using `SpecialCells` you can intersect your range of interest with blank cells, get that range's address instantly and count it's cells without any loop. – JvdV Nov 08 '19 at 23:10

0 Answers0