+ Reply to Thread
Results 1 to 4 of 4

Macro/VBA based on Highlighted Cells?

  1. #1
    Registered User
    Join Date
    03-18-2020
    Location
    Dallas, USA
    MS-Off Ver
    2020
    Posts
    38

    Macro/VBA based on Highlighted Cells?

    Hi everyone! (I originally posted this in the formula forum but was informed that this was a programming/VBA issue). Im not even sure what to Title this post...

    Please see attached the document I will be referencing (ignore the #DIV/0! errors).

    As you can see in Cells H4, I4 and J4, the formula's calculation draws from all data in the left hand side table and it works how it should do.

    Now, in cells K4, L4 and M4, there should be a reflection of the formulas in H4, I4 and J4 respectively but with one difference. To exclude the cells highlighted in yellow.
    The only stipulation you should know is that all formulas in these cells are dependent on being inside a date range (see table starting in cell H18). These 'date ranges' are split up to be P1, P2, P3 etc.

    For example, K4 is based on H4. In this example, H4 includes 'Total Cost' within the date range P1 (1/1/2020 and 2/4/2020) from the left hand side table,
    and K4 should do the same, minus highlighted cells which ALSO fit inside this date range (P1).

    A simple way would be to just have the formula minus certain selected cells, but the highlighting could change, so I would want the formula to follow the highlighting rather than having to manually change it everytime
    a piece of data is changed/added/removed.

    The other thing is that I am also trying to do the same with the table starting H41, which is a replica of the table above it. It totals how many times a 'Source' occurs within a date range. I need it to calculate the same thing but minus
    all anomalies of that 'Source' type, within its respective date range.

    Everything that I am trying to change is highlighted in yellow.
    This could be a series of silly questions but I am unsure as I am pretty new to this level of Excel, Thanks!
    Attached Files Attached Files
    Last edited by TSACov; 03-20-2020 at 09:42 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: Macro/VBA based on Highlighted Cells?

    Does this do what you want?
    With additional column E.
    Enter 1 here if you want to exclude from the calculation.
    Yellow - conditional formatting.
    Look into the attachment.
    Attached Files Attached Files
    Best Regards,
    Maras.

  3. #3
    Registered User
    Join Date
    03-18-2020
    Location
    Dallas, USA
    MS-Off Ver
    2020
    Posts
    38

    Re: Macro/VBA based on Highlighted Cells?

    Hi Maras!

    That is fantastic! I understand what you have done here in regards to SUM formula and I can definitely replicate that from now on.
    My only question now is how to apply that to averages? E.G Cells L4 and M4, in respect to the original averaging formula in I4 amd J4.

  4. #4
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: Macro/VBA based on Highlighted Cells?

    I think it will work well now.
    Attached Files Attached Files

+ 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 row of cells based on a highlighted cell.
    By Gazf5 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 02-28-2020, 08:18 PM
  2. Replies: 1
    Last Post: 06-05-2019, 04:08 PM
  3. Highlighting cells based on another cell being highlighted
    By ZombeeWhisperer in forum Excel General
    Replies: 5
    Last Post: 03-05-2019, 12:29 AM
  4. Creating graph based on highlighted cells
    By Reizor1989 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-10-2017, 01:02 AM
  5. Can you create if statements based on if cells are highlighted?
    By Triscia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2015, 12:07 PM
  6. Copy and Paste based on Red Highlighted Cells
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2013, 12:59 PM
  7. Calculations Based on Highlighted Cells Possible?
    By komobu in forum Excel General
    Replies: 3
    Last Post: 02-26-2011, 04:50 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