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: 454
Default Clear Cells and Worksheet_Change Q

I have the following code that clear cell content with a Range

Sub ClearCells()
Application.ScreenUpdating = False

Sheets("Log").Activate
ActiveSheet.Unprotect Password:="123"
Range("D7").Select
Selection.ClearContents

Application.DisplayFormulaBar = False

Range("D7").Select
Selection.Copy
Range("D7:J30").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=False

Range("D7").Select
ActiveSheet.Protect Password:="123", DrawingObjects:=True,
Contents:=True, Scenarios:=True

End Sub


I also have a Worksheet_Change code that, basically changes a cells
colour when data is selected.

'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "D7:J30" '<==== change to suit

Application.EnableEvents = True
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case LCase(.Value)
Case "Country 1":
.Font.ColorIndex = 2
.Interior.ColorIndex = 3 'red

Case "Country 2":
.Font.ColorIndex = 2
.Interior.ColorIndex = 3 'red

Case "Country 3":
.Font.ColorIndex = 2
.Interior.ColorIndex = 5 'blue

End Select
End With
End If
End Sub


My issue is that when I run my ClearContents macro (it clears the
cells) but I hit debug within the Worksheet_Change code at line (Type
Mismatch):-

Select Case LCase(.Value)

Why is that and how can I 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
Lock or Unlock Range of Cells on Worksheet_Change Event Grahame Coyle Excel Worksheet Functions 3 July 14th 08 12:27 AM
Worksheet_Change with discontinuous cells JKG Excel Programming 1 July 13th 05 07:14 PM
worksheet_change event when multiple cells changed (pasted) noddy26 Excel Programming 13 July 24th 04 09:59 PM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 12:38 PM.

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"