+ Reply to Thread
Results 1 to 9 of 9

Count cells in row based on cell value, highlight row if wrong number or cells.

  1. #1
    Registered User
    Join Date
    04-29-2014
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2013
    Posts
    47

    Count cells in row based on cell value, highlight row if wrong number or cells.

    I want to have a macro that checks the letters in column E and counts the cells in the row, and if the number does not match a preset for those letters combinations the row gets highlighted red.
    In the example attached, row 2 has BLD the column E, so that row should have a total of 7 columns filled out.
    So:
    CP needs 5 count
    BLD needs 7 count
    ED needs 6 count
    TBKR needs 0 count
    And so on…

    I will need to be able to add additional lines of code to the macro to check the more than 150 letter combinations.
    Any help would be appreciated.


    SampleRESULT.xlsxSample.xlsx
    Last edited by gutterball; 09-09-2014 at 04:25 PM.

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Count cells in row based on cell value, highlight row if wrong number or cells.

    Well, it wouldn't be possible to have a 0 count for TBKR, so I adjusted that to 5. This should do it though.

    Please Login or Register  to view this content.
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,531

    Re: Count cells in row based on cell value, highlight row if wrong number or cells.

    Nate beat me to it, and with a nice code too I might add, but since I had worked this up I thought I would reply anyway. It highlights the same two rows that you highlighted in the 'sample' spreadsheet, so I hope it will work on your entire set of data.

    Please Login or Register  to view this content.
    Christ's Peace and Best of Luck

  4. #4
    Registered User
    Join Date
    04-29-2014
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2013
    Posts
    47

    Re: Count cells in row based on cell value, highlight row if wrong number or cells.

    Thank you so much for coding this for me. I hope others and I can learn from your experience.

  5. #5
    Registered User
    Join Date
    04-29-2014
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2013
    Posts
    47

    Re: Count cells in row based on cell value, highlight row if wrong number or cells.

    Thank you for your hard work helping me with this code.

  6. #6
    Registered User
    Join Date
    04-29-2014
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2013
    Posts
    47

    Re: Count cells in row based on cell value, highlight row if wrong number or cells.

    Quote Originally Posted by JeteMc View Post
    Nate beat me to it, and with a nice code too I might add, but since I had worked this up I thought I would reply anyway. It highlights the same two rows that you highlighted in the 'sample' spreadsheet, so I hope it will work on your entire set of data.

    Please Login or Register  to view this content.
    Christ's Peace and Best of Luck
    Great work!

    Can only the highlighted fields be placed onto a second work sheet? Can I add this function to this code?

  7. #7
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Count cells in row based on cell value, highlight row if wrong number or cells.

    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,531

    Re: Count cells in row based on cell value, highlight row if wrong number or cells.

    Gutterball, Thanks for the compliment, I am sorry that I do not have a ready answer for the question about placing the incomplete rows in a second work sheet, I can look into that, but it may take some time. I note that Nate has already added that functionality to his code, so perhaps that would be your better option.

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,531

    Re: Count cells in row based on cell value, highlight row if wrong number or cells.

    I added the functionality for copying and pasting the first 20 cells from each 'incomplete' row to a separate sheet.
    I have also added some comments to the code that may be useful in updating it should the need arise.

    Please Login or Register  to view this content.
    Hope that this will be of some help.
    Christ's Peace and Best of Luck

+ 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. [SOLVED] highlight a series of cells based on the number of days in a date range
    By b2lynch in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-09-2014, 10:48 PM
  2. [SOLVED] Highlight Cells based on Cell Reference on another Worksheet
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-28-2014, 08:24 AM
  3. highlight specific cells in row based on one cell value in same row.
    By mgbanc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2013, 06:58 AM
  4. Highlight 1 cell based on value from other cells
    By freeon in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-10-2013, 01:24 PM
  5. Highlight or colour a cell or cells based on cells in another range.
    By baffld in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-30-2012, 08:41 PM

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