Data Validation from lists - values + formats!

WatfordKev

Board Regular
Joined
Mar 30, 2011
Messages
78
I want to select values from a dropdown based on :

  • lists of data on another worksheet
  • there may be more than 3 values (so Cond Formatting is not an option)
  • I want the formatting from the list cell as well as the values
I know I know I want jam on it too!! :eeek:
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
What kind of formatting? How are your VBA skills?
 
Upvote 0
Hi Glenn

apologies - should have been more clear - just the background colour actually! My VBA skills are novice level, I would say... I do have a coding background tho...
 
Upvote 0
Dear Glenn

OK I am going to look really dopey now... I have altered others' Macros and code, but I don't know how to attach that code (it appears to be exactly what I want) to my dropdown. Sorry to be a pain!
 
Upvote 0
You put your code in the sheet code area ... Right-click the sheet tab and choose View Code from the shortcut menu, and put your code there.
 
Upvote 0
Thanks for this, I've now got it working thanks to you.

I have it working for the font, but the background is not changing. I notice the property on the code is 'Font.ColorIndex' - which doesnt change the background. I tried substituting 'Interior' for 'Font' with no luck - I was wondering if there was a parameter that would format the background too? (I can't determine one!)
 
Upvote 0
It is indeed Interior. Show your code ... you may have made some other minor error.
 
Upvote 0
Hi Glenn

thanks again - this is what I've attempted ("438 - Object doesn't support this method or property")

Private Sub Worksheet_Change(ByVal Target As Range)
If Not IsError(Application.Match(Target.Value, [sourcelist], 0)) Then
Target.Interior.ColorIndex = xlAutomatic
Target.Characters(1, 1).Interior.ColorIndex = Range("SourceList").Cells(Application.Match(Target.Value, [sourcelist], 0)).Characters(1, 1).Interior.ColorIndex
End If
End Sub
 
Upvote 0
Ah, your using almost exactly the same code as for testing the first character of the cell contents ... yours will be muich simpler, similar to this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not IsError(Application.Match(Target.Value, [sourcelist], 0)) Then
   Target.Interior.ColorIndex = Range("SourceList").Cells(Application.Match(Target.Value, [sourcelist], 0)).Interior.ColorIndex
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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