+ Reply to Thread
Results 1 to 3 of 3

Coding for conditional formatting based on relative cells:

  1. #1
    Registered User
    Join Date
    08-09-2012
    Location
    Arkansas
    MS-Off Ver
    Excel 2010
    Posts
    4

    Coding for conditional formatting based on relative cells:

    Hello everyone. I am relatively new to VBA programming and even newer to the forums here. (First post actually.)

    I am creating an excel sheet that I am using to track my attempts at a practice exam bank for a class I am taking. How can I code in VBA to get a cell to change its format based on the cells value compared to another cell in the same row, but a different column?

    Example, if the cell E5 equals AA5, it will shade the cell green, but if it does not equal it is shades it red. If the value in the cell entered = X, I want it to be shaded blue. (It would be great if it could change the color of the font to the same shade the box is colored therefore "hiding the text" that was input so I can't see my previous answer the next time I attempt the question.)
    Then for cell E6, I want it to look at the value in AA6, and so on.
    The cell with the "reference value" will always be column AA, but the cell being input to may be E6, F6, G6, etc. (But E6 through N6 will always have the same answer being AA6)

    There are 26 worksheets in this workbook that the code would apply to, so is there a way to apply this to the entire workbook instead of each worksheet? That is how I coded the Userform was on the "This Workbook" tab, but didn't know if this could be applied the same way.

    I am using a Userform that I created to enter the data into the selected cell. The ideal is to be able to double click a cell on exam attempt 1 (Column), have the userform pop-up, click the answer you want, click enter, and have the pop up go away, and appropriately shade the cell the value was entered into.
    So far I have figured out all of it except the conditional formatting. With this, I only want it to apply the formatting once an input to that cell has been made so that unattempted questions remain blank/white.



    Here is the code I have for my userform

    This is placed in the "This Workbook" section
    Please Login or Register  to view this content.
    while this one is under the User forms code section:

    Please Login or Register  to view this content.

    I appologize if this post extended to the point to be hard to read, but I have researched this to the ends of the internet and have had a hard time finding anything that works.

    Thank you in advance.
    Attached Images Attached Images

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Coding for conditional formatting based on relative cells:

    Hello there,

    What does your userform look like?

    Thanks!

  3. #3
    Registered User
    Join Date
    08-09-2012
    Location
    Arkansas
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Coding for conditional formatting based on relative cells:

    Here is a picture of the current Userform I am using. I will be making slight modifications to it, but they will be minimal.

    UserForm Example.png

+ 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