+ Reply to Thread
Results 1 to 4 of 4

Count no of blank cells per row in multiple sheets in a workbook

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-25-2012
    Location
    CT
    MS-Off Ver
    Excel 2016
    Posts
    134

    Count no of blank cells per row in multiple sheets in a workbook

    Hi All,

    I would like to count the number of black cells for each row in the sheet (I have multiple sheets in the workbook), then print this value in the last column.

    I have this code, which is not very practical (I think I need to generalize it to loop through all rows and all worksheets)


    Sub CountBlank()
    Dim ws As Worksheet
    
    Set ws = Worksheets("March")
    ws.Range("CW2") = Application.WorksheetFunction.CountBlank(ws.Range("C2:CV2"))
    
    End Sub
    Thank in advance for your help.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Count no of blank cells per row in multiple sheets in a workbook

    Sub t()
    Dim sh As Worksheet, r As Long, lc As Long
        For Each sh In ThisWorkbook.Sheets
            lc = sh.Cells.Find("*", , xlFormulas, xlPart, xlByColumns, xlPrevious).Column + 1
            For r = 2 To sh.Cells.Find("*", , xlValues, xlPart, xlByRows, xlPrevious).Row
                sh.Cells(r, lc) = Application.CountBlank(sh.Range(sh.Cells(r, 1), sh.Cells(r, lc - 1)))
            Next
        Next
    End Sub
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Contributor
    Join Date
    01-25-2012
    Location
    CT
    MS-Off Ver
    Excel 2016
    Posts
    134

    Re: Count no of blank cells per row in multiple sheets in a workbook

    Thanks a lot JLGWhiz.

    Exactly what I was looking for. I have just made some modification and addition to accommodate further calculations.

    Thanks once again

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Count no of blank cells per row in multiple sheets in a workbook

    You're welcome,
    regards, JLG

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 07-01-2015, 03:33 PM
  2. Count non blank cells from multiple sheet
    By rizmin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-08-2014, 04:06 PM
  3. [SOLVED] Macro to copy cells from multiple sheets in workbook to multiple sheets in other workbook
    By KeithMale in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2013, 05:37 PM
  4. Using sum over multiple sheets how to ignire blank cells
    By harrycallahan13 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-24-2012, 08:04 PM
  5. Replies: 8
    Last Post: 10-05-2012, 03:44 PM
  6. Count non-blank cells from multiple sheets
    By teitoku in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-25-2010, 01:16 PM
  7. VBA procedure to loop through sheets and count non-blank cells
    By LemonTwist in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2009, 08:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1