+ Reply to Thread
Results 1 to 4 of 4

Formatting cells relative to other cells' values (w/ correct code display)

  1. #1
    Registered User
    Join Date
    06-11-2012
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Formatting cells relative to other cells' values (w/ correct code display)

    I've got a spreadsheet in which all of the data on the sheet is continuously updating based on data located elsewhere in the document.

    What I need to do is establish a code with which I can dictate the formatting of various cells in a row (specific formatting for each column) based on the cell value of another cell within that row.

    For example:

    When the cell value of G10 = "totals"

    I need cells A10, B10, & C10 to be bold, red and font size 20

    ...End Sub


    Now this is just an example, but there are various conditions like this that I need to have apply to the sheet every time anything on the sheet changes.

    I've come close with the following codes, but each is lacking something and I've failed to remedy the problems I list under each:

    Code 1:


    Please Login or Register  to view this content.
    NOTE: This works, but only for the cells "c" for which the value is either "totals - ->" or "subtotals - - >". I need to have othercell formatting change also, not just the cell in which the value is located.


    CODE 2:


    Please Login or Register  to view this content.
    NOTE: ...Literally nothing happens. Now in this case it's only going to be the rows below 206 that the changes apply to (which explains the Target.Row > 206), but I've yet to make this even register a change. What I need is for the macro to run every time anything on the sheet changes, but I may be messing that up somewhere here. Not sure (noob).


    If anyone can help me regain my sanity I would be forever in their debt. Though posting a code that works would solve my problem, any comments on why the above code is failing to satisfy my needs would be much appreciated too. Thank you so much in advance.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Formatting cells relative to other cells' values (w/ correct code display)

    sounds more like conditional formatting is what you need? if you are familiar with CF, give it a try, if not, upload a sample and i will get you started if this will work for you?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Formatting cells relative to other cells' values (w/ correct code display)

    This seems like duplicate posts...
    http://www.excelforum.com/excel-gene...ng-in-vba.html
    http://www.excelforum.com/excel-gene...using-vba.html
    http://www.excelforum.com/excel-gene...ic-column.html

    Not sure where to respond or how to track what has already been answered...

    Based upon your text above, we would need more info. For example,
    I need to have othercell formatting change also, not just the cell in which the value is located.
    What cells? Above, below, separate sheet? Regardless, what you likely need to employ are the .Offset and .Resize commands to your cell c. Or you could use something similar to the code you used in the rng setup in your second block of code (it is your code, correct? Or do you need to reference/thank someone?).

    As for your second block, it is using 'totals' while the one above is 'TOTALS'. They are checking different text.

    Pauley

  4. #4
    Registered User
    Join Date
    06-11-2012
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Formatting cells relative to other cells' values (w/ correct code display)

    I apologize for the re-posts, or near re-posts. The little information I enabled you to afford actually helped and I have been able to put this issue to rest. Thank you again.

+ 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