+ Reply to Thread
Results 1 to 6 of 6

Format a cell based on format of another cell?

  1. #1
    Registered User
    Join Date
    05-12-2019
    Location
    Utah, USA
    MS-Off Ver
    2010 and 365
    Posts
    3

    Format a cell based on format of another cell?

    Hi! I'm trying to figure out if this is possible. I have two spreadsheets containing a list of items within categories. The same items are in each category; the only difference is the name of the category.

    For example, if the categories are Red, Blue, and Black, the items under each category might be Shirt, Pants, and Dress. Using this example I made a spreadsheet showing which Red, Black, and Blue items I have - Shirts, Pants, or Dresses. When I have the shirt, pants, or dress of a certain color I change the color of the cell. When I don't have the shirt, pants, or dress of a certain color I do nothing to the cell. There are no values in the cells; just colored cells for positive and plain white cells for negative.

    In my second spreadsheet, I want to do the opposite of the first. I want to see which shirts, pants, and dresses I DON'T have of the colors red, blue, and black (using the above example). Instead of having to manually color the cells in the second spreadsheet, I want it to look at the first and apply cell colors to the cells from the first spreadsheet that are white. I tried to use conditional formatting but can't seem to find a way to assign a value to a cell based on its formatting. If I assign a value of "1" to colored cells and "2" to blank cells, for example, the second spreadsheet can use a duplicate of the first table but only apply formatting to the cells with a value of "2" from the first spreadsheet.

    As a shorter way to do this, I would prefer to just have the second spreadsheet format itself by looking at the formatting of the first, without having to apply a value to cells of different colors/formats.

    Is there a formula/function in Excel that can look at a cell's formatting and either apply a value to it or format another cell based on the format (or lack thereof) of the first cell? I've attached an example picture to show what I'm trying to do. Can someone please give me some advice? Thank you.
    Attached Images Attached Images

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,445

    Re: Format a cell based on format of another cell?

    Hi and welcome
    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Format a cell based on format of another cell?

    You can do this with a user defined function

    Please Login or Register  to view this content.

    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a Sheet 2 A1, enter =GetNumberFromFormat(Sheet1!A1)
    Remember to save the workbook as a macro enabled workbook .xlsm
    Martin

  4. #4
    Registered User
    Join Date
    05-12-2019
    Location
    Utah, USA
    MS-Off Ver
    2010 and 365
    Posts
    3
    Quote Originally Posted by Pepe Le Mokko View Post
    Hi and welcome
    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Thank you. I still have that little spreadsheet in the computer. I'll attach it instead of a picture.

  5. #5
    Registered User
    Join Date
    05-12-2019
    Location
    Utah, USA
    MS-Off Ver
    2010 and 365
    Posts
    3
    Quote Originally Posted by mrice View Post
    You can do this with a user defined function

    Please Login or Register  to view this content.

    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a Sheet 2 A1, enter =GetNumberFromFormat(Sheet1!A1)
    Remember to save the workbook as a macro enabled workbook .xlsm
    Thank you. I am not familiar at all with vba so I have some questions.

    In your example, where you put the word "MyRange," I should instead put the name of the range I'm trying to work with, correct?

    Please forgive my ignorance. I want to learn vba. In parentheses after the line GetNumberFromFormat where it says "(MyRange as Range)," should I type exactly that? For example, if the range I'm working with was named "Clothes," should I type exactly:
    Function GetNumberFromFormat(Clothes As Range)
    Or
    Function GetNumberFromFormat(Clothes)
    Or something else?

    My actual spreadsheet had nothing to do with clothes but it seemed an easy example.

    So if I understand this correctly it says:
    If there is no formatting the value is 1
    If there is formatting the value is 2
    Otherwise the value is 0?

    I'm going to try to look this up and learn from it. Thank you again for taking the time to write this out. Once again, please forgive my absolute ignorance of the language.

    Shado
    Last edited by shadokat; 05-13-2019 at 07:58 AM.

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Format a cell based on format of another cell?

    Please Login or Register  to view this content.
    You don't need to change the VBA - just specify the range in the brackets as shown above

+ 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. Replies: 4
    Last Post: 10-05-2017, 09:37 AM
  2. Changing Cell format based on another cells format.
    By MrStevie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-05-2017, 03:02 PM
  3. [SOLVED] How to Sum based on partial match of a cell in number format (not text format)
    By NBehrens in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-24-2017, 12:34 PM
  4. Replies: 4
    Last Post: 03-13-2015, 02:32 AM
  5. Replies: 1
    Last Post: 07-03-2014, 06:33 AM
  6. automatically format cell based on another cell's format
    By nativeplanter in forum Excel General
    Replies: 7
    Last Post: 04-11-2012, 08:23 PM
  7. how do i format a cell based on format of a range of cells?
    By Chris Hardick in forum Excel General
    Replies: 2
    Last Post: 04-03-2006, 03:55 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