VBA: Need help to assign codes to items chosen by the user for conditional formatting

rizzo93

Active Member
Joined
Jan 22, 2015
Messages
303
Office Version
  1. 365
I know this looks daunting, but please don't turn away just yet. :) The concept of what I'm trying to achieve is simple, but requires a lot of detail to paint you the right picture.

I'm trying to create a way for users to assign colors to projects in a dynamic list. So when the user makes a choice from slicers, the colors will follow the projects they've been assigned to no matter where they show up in the list.

Here's what I've done so far:


  1. Cells on Sheet A are referencing cells in a pivot table on Sheet B (which is hidden from the user).
  2. Slicers for that pivot table exist on Sheet A, so when the user makes a choice, the data filters accordingly. This way I can have the data filtered more easily while I also make other calculations that correspond to the projects being displayed.
  3. Each project has a unique ID. That ID is also on the same row as the project, but will be hidden from view. I do this so that I can perform other calculations elsewhere. Plus, I think they will be useful for what I'm trying to do with assigning colors.
  4. In another column on the same row as the project (still on Sheet A) are cells that contain a number from 0 to 10. Using conditional formatting, each number will colorize the cell the project is in with a different color, BUT that color must follow the project as the list is filtered and causes the project to move up or down.
  5. I've created a userform for users to assign colors to projects. On this form I want the user to:

    a. left-click on one or more projects (although I can't get Ctrl-click to work to select more than one for some reason).
    b. then choose a radio button that's next to the color they want to assign to that project(s)
    c. then click a button called "Assign Colors" which will then enter the corresponding number (0-10) into a cell on another worksheet (Sheet C) for the project(s) they've chosen. Users don't need to know anything about these color numbers; all they'll see are small tiles of colors with radio buttons next to them.

So back on Sheet A, that column I mentioned in #4 above will look at the project ID next to it (using INDEX and MATCH) and retrieve the corresponding "color" number that's on Sheet C for that project, thus providing the condition for the conditional formatting to occur.

Still with me? :)

Though I'm rather new to VBA, I can "get" data from and "put" data into cells. The big issue for me is how do I identify what project(s) the user has selected in the userform and "put" the corresponding color number into Sheet C so that Sheet A can know which conditional format to use?

Or perhaps there is a simpler way to do this?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,224,000
Messages
6,175,896
Members
452,681
Latest member
jlcm0924

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top