Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2006

Tip: Looking for answers? Try searching our database.

Drop Down list

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aaaaa - 30 Dec 2006 23:55 GMT
I've created a list of 10 names.  Each name is in a different font and
color.

These 10 names make up the possible selections for a drop down list.  When I
select a name from the list and excel enters it into the cell, the font
color and type that was originally given to the it when the list was created
no longer follows the selection.

Is there a way to have the correct font color and size follow the selection
based upon what name is picked.
Martin Fishlock - 31 Dec 2006 01:33 GMT
Hi,

Try this little bit of code. It is worksheet code so it needs to be placed
in the code for the worksheet where the datalist is.

A word of warning, it breaks down if the cell is cleared with spaces.  

May somebody could comment on a solution. The error occurs when an error
condition occurs in the cell - ie you enter rubbish it can't match it so the
datavalidiation kicks (cancel ok) but retry causes the problem you clear the
bad entry and then the application.enableevents =false causes an error.

The two changes you need to make are the const refences.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
     
   Const cszCell As String = "D1"
   Const cszTable As String = "A1:A10"
   Dim idx As Variant
   
   If Me.Range(cszCell) = "" Or _
       Trim(Me.Range(cszCell)) = " " Then Exit Sub

   Application.EnableEvents = False
   On Error GoTo error_pickup
   
   If Not (Intersect(Target, Me.Range(cszCell)) _
           Is Nothing) Then
       idx = Application.WorksheetFunction.Match( _
           Me.Range(cszCell), Me.Range(cszTable), 0)
       If IsNumeric(idx) Then
           Me.Range(cszTable).Cells(1, 1).Offset( _
               idx - 1, 0).Copy
           Me.Range(cszCell).PasteSpecial xlPasteFormats
       End If
   End If
error_pickup:
   Application.CutCopyMode = False
   Application.EnableEvents = True
End Sub

Signature

Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.

> I've created a list of 10 names.  Each name is in a different font and
> color.
[quoted text clipped - 6 lines]
> Is there a way to have the correct font color and size follow the selection
> based upon what name is picked.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.