+ Reply to Thread
Results 1 to 4 of 4

Simple macro subtract two numbers with colored backgrounds

  1. #1
    Registered User
    Join Date
    02-22-2018
    Location
    buffalo ny
    MS-Off Ver
    excel 2013
    Posts
    2

    Simple macro subtract two numbers with colored backgrounds

    In my spreadsheet in column A I will have a series of numbers and colored cells.

    I mostly uses green and red, Green is a buy and red is a sell. I want a macro that can subtract the red from the last green cell. They may be 5 cells apart sometimes more.

    Thanks,

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Simple macro subtract two numbers with colored backgrounds

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.


    To add a file to a post

  3. #3
    Registered User
    Join Date
    02-22-2018
    Location
    buffalo ny
    MS-Off Ver
    excel 2013
    Posts
    2

    Re: Simple macro subtract two numbers with colored backgrounds

    Attached is simple example i want to put macro in B10 that subtracts the last green cell from a 10. Sometimes that distance is 10 cells sometimes 5.
    Thanks,
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: Simple macro subtract two numbers with colored backgrounds

    Put this code into a standard codemodule of your workbook, and save the file as a macro-enabled .xlsm. Then use the function like so:

    Look for your green fill
    =LGC(A10,A1:A9)

    or

    Look for any fill
    =LCCell(A10,A1:A9)

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

+ 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] Confussed in Simple Add + Subtract formula
    By pipsmultan in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 06-29-2015, 12:10 AM
  2. [SOLVED] Simple macro to insert a new row if 2 numbers exceeding 99999999 are next to each other
    By ostego in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2014, 07:26 AM
  3. [SOLVED] If the difference more than 0.2 than colored numbers
    By ALEZI in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-03-2013, 05:36 PM
  4. Simple Add/Subtract with loop
    By hjin25 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-14-2012, 01:15 AM
  5. [SOLVED] Macro - Place numbers when row is colored.
    By Jessy142 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-11-2012, 02:52 AM
  6. Replies: 6
    Last Post: 11-03-2011, 04:44 PM
  7. How do you create simple add/subtract formula?
    By Suomalainen in forum Excel General
    Replies: 6
    Last Post: 07-01-2008, 03:18 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