+ Reply to Thread
Results 1 to 4 of 4

Can I do this with conditional formatting? Don't know where to start--countifs, for loops?

  1. #1
    Registered User
    Join Date
    06-11-2012
    Location
    Calgary
    MS-Off Ver
    Excel 2007-2010
    Posts
    25

    Can I do this with conditional formatting? Don't know where to start--countifs, for loops?

    Hello all,

    I have set up a macro for quite a few conditional formatting rules that I can run on a very large daily spreadsheet to highlight all the things I need to take a second look at--this column is less than this number, that column has text not equal to these eight different acceptable values, that sort of thing. I know just enough about coding to be dangerous to myself and others, and with enough googling I can usually work through anything, so I've fine-tuned it all well enough.

    But there's one thing I don't even know where to start on, so I'm asking for help.

    Check column A for duplicate values (employee names).
    Where a duplicate is found, check a text entry in column C.
    If the value in column C is "Value X" or "Value Y," take the number in column B and keep a running tally of these. (If the value in column C is anything other than "Value X" or "Value Y," do not add column B's value to the tally.)
    Highlight all the duplicate values in column A if the running tally comes to more than 40.

    I've attached an example with the expected output if that helps. (Edit: Example has Value A and Value B as the ones to pay attention to instead of X and Y. Oops)

    Right now I'm just using the conditional formatting preset to highlight ALL duplicates in column A and looking at them that way, but it's a really large spreadsheet, and most of the duplicates don't need my attention.

    It's better than how they trained me anyway, which was "what's conditional formatting? Just scroll through and eyeball them all" --but I know I can do better! Haha. Thanks in advance.
    Attached Files Attached Files
    Last edited by Shanyn; 06-13-2013 at 11:41 AM.

  2. #2
    Registered User
    Join Date
    06-12-2013
    Location
    USA
    MS-Off Ver
    excel 2007
    Posts
    9

    Re: Can I do this with conditional formatting? Don't know where to start--countifs, for lo

    I'm not sure of the commands to do what i have in 'quotes', but i bet you can find them online or know how to do them already?

    dim i = integer
    i=0
    do until 'whatever your condition is'
    if 'cell in column a duplicate' then
    if 'cell in column c is value x or value y' then
    i= i + 'value in column b'
    else
    end if
    else
    end if
    loop
    if b > 40 then
    'highlight duplicates in column a'
    else
    end if

    I'm sorry if that wasn't helpful, I'm sure someone else here can fill in what I missed/correct me.
    I think that would work though.

  3. #3
    Registered User
    Join Date
    06-11-2012
    Location
    Calgary
    MS-Off Ver
    Excel 2007-2010
    Posts
    25

    Re: Can I do this with conditional formatting? Don't know where to start--countifs, for lo

    Thank you for taking the time to give me a starting point. Writing loops is a weakness of mine.

    Quote Originally Posted by frongi View Post
    do until 'whatever your condition is'
    I can fill in the rest of the blanks on my own, but I'm not sure what to do with this line of it.

  4. #4
    Registered User
    Join Date
    06-12-2013
    Location
    USA
    MS-Off Ver
    excel 2007
    Posts
    9

    Re: Can I do this with conditional formatting? Don't know where to start--countifs, for lo

    for the do until, that just means keep looping until a certain condition is met. in this case, i would guess the condition is that you have reached the last row. so you actually might be looking for:

    dim i as integer
    i = 0
    ' this activates cell A1
    Worksheets("Sheet1").Select
    Range("A1").Select
    do until 'there are no more rows left to be checked'
    if 'activecell is a duplicate' then
    if 'cell 2 rows over from the active cell is value x or value y' then
    i= i + 'value in column b'
    else
    end if
    else
    end if
    ActiveCell.Offset(1, 0).Select
    loop
    if i>40 then ...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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