Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VB script modification (continued from yesterday)

OK, started with...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel
As Boolean)

If Target.Interior.ColorIndex = 50 Then
Target.Interior.ColorIndex = xlNone
Else
Target.Interior.ColorIndex = 50
End If

Cancel = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
End Sub

Modified to...

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Target.Interior.ColorIndex = Choose(Val(Target.Value), 3, 3, 4, 4)
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
End Sub

....based on code from FSt1 and Rick Rothestein. (Thanks a ton, BTW!) Works
great, except the color doesn't change on the double click anymore. It now
changes after the cell is DC'ed, then another cell is clicked. I'm playing
with the code to try to understand why, but with little effect.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VB script modification (continued from yesterday)

Forgot to mention to Rick...

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Target.Interior.ColorIndex = Choose(Val(Target.Value), 3, 3, 4, 4)
End Sub

works as mentioned above. In one of your earlier replies, you modified to
include the original header....

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel
As Boolean)
On Error Resume Next
Target.Interior.ColorIndex = Choose(Val(Target.Value), 3, 3, 4, 4)
End Sub

....which, oddly enough, did not work. (No errors, just doesn't function.)
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VB script modification (continued from yesterday)


Also, the code from FSt1...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel
As Boolean)
If Target.Value = "" Then
Target.Interior.ColorIndex = xlnone
Else
If Target.Value = 1 Or Target.Value = 2 Then
Target.Interior.ColorIndex = 3
Else
If Target.Value = 3 Or Target.Value = 4 Then
Target.Interior.ColorIndex = 4
End If
End If
End If
End Sub

....generates a Runtime error 13 - type mismatch on the line

If Target.Value = "" Then

I'll take a solution to either issue. Thanks again for all the help.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Yesterday Loadmaster Excel Worksheet Functions 5 August 8th 08 09:41 PM
I really need help. Need a formula. Need it yesterday. Dennis New Users to Excel 1 March 12th 07 08:53 PM
continuation from yesterday Mindy Excel Discussion (Misc queries) 4 June 22nd 06 11:13 PM
Sub From Yesterday Josh in Tampa Excel Programming 4 October 23rd 03 04:47 PM


All times are GMT +1. The time now is 08:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"