LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need help modifying VB script

I am working on a script to change the background color of a cell when it is
double-clicked. So far, I have this script, which works fine.....

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

I am trying to modify this so that the target color changes based on the
cell value. For instance, this is a grading sheet, and I'd like all scores
of 1 or 2 to change to red, while 3 and 4 change to green. I've tried using
an IF THEN statement around the above code to look at the value of the cell
but it isn't working, likely because of the coding. I wrote:

IF Target.Value "2" Then...(original code)
Else...(Original code with different color value)

I am getting an error running this, and am hoping someone can tell me why.
I haven't programmed script in a long time, so I'm hoping it's a simple fix.

Thanks!
 
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
Modifying If Statement Workbook Excel Worksheet Functions 5 February 4th 09 01:23 PM
Modifying Macro simplymidori[_2_] Excel Discussion (Misc queries) 3 April 13th 08 04:17 PM
help Modifying ParTeeGolfer Excel Worksheet Functions 0 January 27th 05 10:07 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM
Help modifying code BruceJ[_2_] Excel Programming 1 December 10th 03 12:52 AM


All times are GMT +1. The time now is 11:16 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"