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,302
Default I'm missing something here....

Hi BeSmart,

You can only have one Worksheet_Change procedure in the worksheet module.

You need to combine the two into a single procedu:

Private Sub Worksheet_Change(ByVal Target As Range)

Set LastEnteredCell = Target

For Each c In Target
If Not Intersect(c, [M14:GR605]) Is Nothing Then
Target.Cells.Interior.ColorIndex = xlNone
If IsNumeric(Target.Value) Then
If Target.Value 0 Then
Select Case LCase(Cells(Target.Row, 5).Text)
Case Is = "Retail"
Target.Cells.Interior.ColorIndex = 38
Case Is = "Quick"
Target.Cells.Interior.ColorIndex = 37
Case Is = "Jewel"
Target.Cells.Interior.ColorIndex = 34
Case Is = "Brand"
Target.Cells.Interior.ColorIndex = 36
Case Is = "Other"
Target.Cells.Interior.ColorIndex = 2
Case Is = "Generic"
Target.Cells.Interior.ColorIndex = 2

End Select
End If
End If
End If
Next c
End Sub

I have not looked at the code itself.

---
Regards,
Norman



"BeSmart" wrote in message
...
Hi all
I have existing code on an Excel 2000 spreadsheet that looks like this:

================================================== ==
Option Explicit

Public LastEnteredCell As Range
---------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Set LastEnteredCell = Target
End Sub
-----------------------------------------------------------------------
Sub goBack()
LastEnteredCell.Select
End Sub
-------------------------------------------------------------------------
......(There are then ClickButton codes after this)
================================================== ===
The current code works perfectly.

I want to copy and paste some new Worksheet_change code (see it below)
that
was written in a different workbook and has to apply to this worksheet.
It applies conditional formatting based on 5 conditions when users enter a
value into a range.
When I paste this code into the top of the existing codes, the End Sub is
appears but the dividing line don't (merging my code with "Option
Explicit"
etc) and when I test the code I start getting "Compile errors", "Ambiguous
name detected: Worksheet_Change"

What am I doing wrong? How do I get this new code into my worksheet and
retain the prior functions? I tried pasting it to the end of the code -
but
this made no difference.

New code:
=================================================
Private Sub Worksheet_Change(ByVal Target As Range)

For Each c In Target
If Not Intersect(c, [M14:GR605]) Is Nothing Then
Target.Cells.Interior.ColorIndex = xlNone
If IsNumeric(Target.Value) Then
If Target.Value 0 Then
Select Case LCase(Cells(Target.Row, 5).Text)
Case Is = "Retail"
Target.Cells.Interior.ColorIndex = 38
Case Is = "Quick"
Target.Cells.Interior.ColorIndex = 37
Case Is = "Jewel"
Target.Cells.Interior.ColorIndex = 34
Case Is = "Brand"
Target.Cells.Interior.ColorIndex = 36
Case Is = "Other"
Target.Cells.Interior.ColorIndex = 2
Case Is = "Generic"
Target.Cells.Interior.ColorIndex = 2

End Select
End If
End If
End If
Next c
End Sub
==================================================
Appreciate any help
--
Thank for your help
BeSmart



 
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
Missing MB Gotroots Excel Discussion (Misc queries) 1 December 2nd 09 02:21 PM
#Missing Shirley Excel Worksheet Functions 1 August 28th 08 10:22 PM
Something Missing Looping through Excel Worksheet Functions 4 December 18th 07 02:42 PM
add-ins missing Newbie Excel Worksheet Functions 1 March 7th 06 08:29 PM
Toolbars Missing, And option to Add Missing SmeetaG Excel Discussion (Misc queries) 3 October 19th 05 11:43 AM


All times are GMT +1. The time now is 09:28 AM.

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

About Us

"It's about Microsoft Excel"