Results 1 to 6 of 6

count blank cells in a range using VBA

This is a discussion on count blank cells in a range using VBA within the Excel Questions forums, part of the Question Forums category; Hi,...

  1. #1
    Board Regular
    Join Date
    Sep 2006
    Posts
    73

    Default count blank cells in a range using VBA

    Hi,

  2. #2
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    24,735

    Default Re: count blank cells in a range using VBA

    Quote Originally Posted by divuraj View Post
    Hi,
    Hi to you too! What's your question?
    Hope this helps, good luck.
    Peter

    - Read: Posting Guidelines, Forum Rules & FAQs
    - Want to post a small screen shot? Try one of these Excel jeanie, MrExcel HTML Maker or Borders-Copy-Paste (To test: Test Here)
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the VBHTML Maker

  3. #3
    VoG
    VoG is online now
    MrExcel MVP
    Moderator
    VoG's Avatar
    Join Date
    Jun 2002
    Location
    127.0.0.1
    Posts
    61,511

    Default Re: count blank cells in a range using VBA

    Guessing

    Code:
    Sub test()
    MsgBox WorksheetFunction.CountIf(Range("A1:A100"), "")
    End Sub

  4. #4
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    24,735

    Default Re: count blank cells in a range using VBA

    Well, for my guess then:

    Sub test()
        MsgBox WorksheetFunction.CountBlank(Range("A1:A100"))
    End Sub
    Hope this helps, good luck.
    Peter

    - Read: Posting Guidelines, Forum Rules & FAQs
    - Want to post a small screen shot? Try one of these Excel jeanie, MrExcel HTML Maker or Borders-Copy-Paste (To test: Test Here)
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the VBHTML Maker

  5. #5
    Board Regular
    Join Date
    Sep 2006
    Posts
    73

    Default count blank cells in a range using VBA

    Hi,

    i have few blank cells in column A. i find the last row containing data in column A and then i am trying to find the blank cells in column A which works fine.

    once i find a blank cell in column A, i would need to select the range of cells till i find the cell with values,basically count the number of blank cells within a range.

    now within this range i have values in column E, i need to find Min of these values and delete all blank rows which are not Min.

    for eg, i identified first blank cell in A72, so i go to E71 and select the range of cells in E column till i find a non blank cell in A column which is E71:E72 in this case. i have 296 in E71 and 359 in E72, so i find the Min which is 296, so i delete the row which has 359.

    Hope this explains.

    please help.

    Thanks,
    divuraj.

  6. #6
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    24,735

    Default Re: count blank cells in a range using VBA

    Quote Originally Posted by divuraj View Post
    for eg, i identified first blank cell in A72, so i go to E71 and select the range of cells in E column till i find a non blank cell in A column which is E71:E72 in this case. i have 296 in E71 and 359 in E72, so i find the Min which is 296, so i delete the row which has 359.

    Hope this explains.
    It's still not clear to me. For example,

    a) if your first blank cell is A72, why are you looking in E71?

    b) in your example, if E71 was 359 and E72 was 296, would you have deleted row 71 - that is a row that had data in column A?

    Perhaps it might help if you could explain which rows below should be deleted, and why.

    divuraj

     ABCDE
    691   300
    701   299
    711   296
    72    359
    731   380
    741   250
    751   275
    76    399
    77    100
    78    222
    79    301
    801   600
    811   450
    82    450
    83    450
    841   444


    Excel tables to the web >> Excel Jeanie HTML 4
    Hope this helps, good luck.
    Peter

    - Read: Posting Guidelines, Forum Rules & FAQs
    - Want to post a small screen shot? Try one of these Excel jeanie, MrExcel HTML Maker or Borders-Copy-Paste (To test: Test Here)
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the VBHTML Maker

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com