vba excel - loop through each cell table within column to test if empty

devofish

Board Regular
Joined
Dec 10, 2016
Messages
68
Hello all. I want to check if a column within a table has been completely populated with input from the user. If there is missing data input, the routine exits. I've tried to use the WorksheetFunction.CountA(rng) function, but I'm not getting any results. Do I need to insert a loop function instead? Any help with this is greatly appreciated.
Code:
Private Sub CheckCell() 'check to ensure all dates are entered
    Dim iCell       As Range
    Dim LastRow     As Long
    Dim lstObj      As ListObject
    Dim ws1, ws2    As Worksheet        
    
    Set wb = ThisWorkbook
    Set ws1 = wb.Sheets(1)
    Set ws2 = wb.Sheets(2)
    Set lstObj = ws1.ListObjects("Table")-1 'table contains header

    LastRow = lstObj.Range.Rows.Count
    Set iCell = ws1.Range("F2:F" & LastRow)
    If WorksheetFunction.CountA(iCell) < iCell.Count Then
        Exit Sub 'there are still stop dates unfilled so exit sub
    Else
        ws2.Range("D9").value = Now()
    End If    
    Application.EnableEvents = True
End Sub
 
Last edited:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,216,609
Messages
6,131,723
Members
449,667
Latest member
PSAv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top