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 / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Hi all,

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francois - 23 May 2008 13:11 GMT
Private Sub Worksheet_Change(ByVal Target As Range)

   
  On Error GoTo ws_exit:
  Application.EnableEvents = False
  If Not Intersect(Target, Me.Range("C1:C50")) Is Nothing Then
      With Target
          Select Case UCase(.Value)
              Case "A":   .Interior.ColorIndex = 3
              Case "B":   .Interior.ColorIndex = 4
              Case "C":   .Interior.ColorIndex = 5
              Case "D":   .Interior.ColorIndex = 6
              Case "E":   .Interior.ColorIndex = 7
              Case "F":   .Interior.ColorIndex = 8
              Case "G":   .Interior.ColorIndex = 9
              Case "H":   .Interior.ColorIndex = 10
              Case "I":   .Interior.ColorIndex = 11
              Case "J":   .Interior.ColorIndex = 12
              Case "K":   .Interior.ColorIndex = 13
             
             
          '    Selection.Font.ColorIndex = 3
             
          End Select
      End With
  End If

ws_exit:
  Application.EnableEvents = True
End Sub
Mike H - 23 May 2008 13:21 GMT
Is there a question associated with this?

> Private Sub Worksheet_Change(ByVal Target As Range)
>
[quoted text clipped - 26 lines]
>    Application.EnableEvents = True
> End Sub
Stefi - 23 May 2008 13:23 GMT
What is the question?
Stefi

„Francois via OfficeKB.com” ezt írta:

> Private Sub Worksheet_Change(ByVal Target As Range)
>
[quoted text clipped - 26 lines]
>    Application.EnableEvents = True
> End Sub
Francois - 23 May 2008 13:24 GMT
Oh dear,  Sorry this post was meant to be deleted......duplicated

>Private Sub Worksheet_Change(ByVal Target As Range)
>
[quoted text clipped - 26 lines]
>   Application.EnableEvents = True
>End Sub
Rick Rothstein (MVP - VB) - 23 May 2008 15:55 GMT
If you come back to this thread, you might find it interesting that this
part of your code...

          Select Case UCase(.Value)
              Case "A":   .Interior.ColorIndex = 3
              Case "B":   .Interior.ColorIndex = 4
              Case "C":   .Interior.ColorIndex = 5
              Case "D":   .Interior.ColorIndex = 6
              Case "E":   .Interior.ColorIndex = 7
              Case "F":   .Interior.ColorIndex = 8
              Case "G":   .Interior.ColorIndex = 9
              Case "H":   .Interior.ColorIndex = 10
              Case "I":   .Interior.ColorIndex = 11
              Case "J":   .Interior.ColorIndex = 12
              Case "K":   .Interior.ColorIndex = 13

          '    Selection.Font.ColorIndex = 3

          End Select

can be replaced by this shorter piece of code...

          If .Value Like "[A-Ka-k]" Then
              .Interior.ColorIndex = Asc(UCase(.Value)) - 62
          End If

I wasn't sure what the commented out statement was for; but if you meant it
to go in a Case Else block, then you would duplicate that by adding an Else
section to the If-Then block to handle it.

Rick

> Private Sub Worksheet_Change(ByVal Target As Range)
>
[quoted text clipped - 24 lines]
>   Application.EnableEvents = True
> End Sub
 
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.