Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Does anyone have any semi-easy to follow VBA code they have written to create
a Case function? I think I understand most of it, but seeing code I know functions properly will probably tie up some loose ends. thanks! |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Here's a small example:
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range If Target.Cells.Count 1 Then Exit Sub On Error GoTo ws_exit: Set rng = Application.Intersect(Target, Me.Range("a:a")) If rng Is Nothing Then Exit Sub With Target Select Case LCase(.Value) Case Is = "monday": .Interior.ColorIndex = 3 Case Is = "tuesday": .Interior.ColorIndex = 4 Case Is = "wednesday": .Interior.ColorIndex = 5 Case Is = "thursday": .Interior.ColorIndex = 7 Case Is = "friday": .Interior.ColorIndex = 6 Case Is = "saturday": .Interior.ColorIndex = 8 Case Is = "sunday": .Interior.ColorIndex = 13 Case Else .Interior.ColorIndex = xlNone End Select End With ws_exit: End Sub But if you search the *excel* newsgroup in google groups for "select case", you'll find a lot more to look at. Mariano wrote: Does anyone have any semi-easy to follow VBA code they have written to create a Case function? I think I understand most of it, but seeing code I know functions properly will probably tie up some loose ends. thanks! -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks Dave, thats perfect
"Dave Peterson" wrote: Here's a small example: Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range If Target.Cells.Count 1 Then Exit Sub On Error GoTo ws_exit: Set rng = Application.Intersect(Target, Me.Range("a:a")) If rng Is Nothing Then Exit Sub With Target Select Case LCase(.Value) Case Is = "monday": .Interior.ColorIndex = 3 Case Is = "tuesday": .Interior.ColorIndex = 4 Case Is = "wednesday": .Interior.ColorIndex = 5 Case Is = "thursday": .Interior.ColorIndex = 7 Case Is = "friday": .Interior.ColorIndex = 6 Case Is = "saturday": .Interior.ColorIndex = 8 Case Is = "sunday": .Interior.ColorIndex = 13 Case Else .Interior.ColorIndex = xlNone End Select End With ws_exit: End Sub But if you search the *excel* newsgroup in google groups for "select case", you'll find a lot more to look at. Mariano wrote: Does anyone have any semi-easy to follow VBA code they have written to create a Case function? I think I understand most of it, but seeing code I know functions properly will probably tie up some loose ends. thanks! -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert number into words | Excel Discussion (Misc queries) | |||
I NEED HELP with the SPELLNUMBER Function | Excel Worksheet Functions | |||
How can i change this VBA project According to Indian Numeric | Excel Discussion (Misc queries) | |||
Amount or Numbers in Words | New Users to Excel | |||
Is there a formula to spell out a number in excel? | Excel Worksheet Functions |