+ Reply to Thread
Results 1 to 5 of 5

Macro relative to and initiated by a cell that contains an equation

  1. #1
    Registered User
    Join Date
    07-29-2014
    Location
    Lafayette, Louisiana
    MS-Off Ver
    2013
    Posts
    2

    Macro relative to and initiated by a cell that contains an equation

    OK so I have spent about 4 hours trying to figure something out that someone can do in about 5 seconds.

    I have a table with 3 columns and many rows. If the values in column A equal column B, then column C says "Good", if not then it says "Bad". For example if A3=B3, then C3= Good.

    I want all the rows that contain the word "Good" in column 3 to highlight green. I am going to have 1000 rows eventually so it needs to be simple.

    Example:

    A B C
    1)--2--2--Good
    2)--3--7--Bad
    3)--5--5--Good

    * In the above example I would want rows 1 and 3 to highlight green because their values in A and B are equal.

    It is more complicated than this but I tried to simplify it. Please help!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,091

    Re: Macro relative to and initiated by a cell that contains an equation

    You don't need a macro, just use Conditional Formatting.

    Select all the cells, A2 down to C4 and use the CF formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    See the example workbook.

    Regards, TMS
    Attached Files Attached Files
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,803

    Re: Macro relative to and initiated by a cell that contains an equation

    You probably need to explain in what way it is more complicated than this. What you described almost certainly does not need any kind of macro. What you described (change color of row based on the condition that column 3 in that row = "good") should be easily accomplished using conditional formatting. http://office.microsoft.com/en-us/ex...062.aspx?CTT=1
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Registered User
    Join Date
    07-29-2014
    Location
    Lafayette, Louisiana
    MS-Off Ver
    2013
    Posts
    2

    Re: Macro relative to and initiated by a cell that contains an equation

    Thanks for the reply. I understand how to do this using conditional formatting, but I figured if I could learn how to do this using VBA I could do what I actually want to do which is a bit more complicated.

    However here is what I really want to happen:
    If:
    a cell in column A equals the cell in the same row of column B,
    Then:
    Column D in that same row should equal "Good", if not it should equal "Bad"
    and
    The button in column C in that same row should be deleted.


    ----A--B--C-------D
    1)--2--2--Button--Good
    2)--3--7--Button--Bad
    3)--5--5--Button--Good


    And I need this to happen for 1000's of rows below

    Thanks guys!

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,803

    Re: Macro relative to and initiated by a cell that contains an equation

    Sorry to leave you hanging on this one.

    Column D should be a simple IF() function: =IF(A1=B1,"Good","Bad")

    The real difficulty (at least for me) is the "button" in column C. Since I don't use buttons in my spreadsheets, I am not at all familiar with how to use them. In an overall sense, the code (assuming VBA would be the only way to manipulate these buttons like this) would look roughly like this code snippet:
    Please Login or Register  to view this content.
    I have no idea what the code to manipulate the buttons would look like, so someone else will need to step in and help with that.

+ 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] cell text is an equation - use that equation to populate an answer in another cell
    By JOBSTRESS in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-08-2013, 01:08 PM
  2. [SOLVED] Adding value to cell directly below the checkbox that initiated the userform
    By weige1989 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-25-2013, 04:12 AM
  3. change event macro to evaluate windows user who initiated the change then send email
    By pmanoloff in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-23-2012, 03:31 PM
  4. Autofill Relative Equation Across Sheets
    By abcd12 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-01-2008, 03:27 PM
  5. how do i setup a macro which is initiated by a button?
    By An Excel Nut in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-05-2005, 12:06 PM

Tags for this Thread

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