Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheet Change Error
Maybe...
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Then Exit Sub If Intersect(Target, Me.Range("B2:B30")) Is Nothing Then Exit Sub Application.EnableEvents = False If Target.Value 0 Then Target(1, 5).Value = Randomize(Rnd) Target(1, 7).Value = Randomize2(Rnd) End If If Target.Value = 0 Then Target(1, 5).Value = 0 Target(1, 7).Value = 0 End If Application.EnableEvents = True End Sub mslabbe wrote: Worksheet Change Error I was trying to get a cell change run a macro...got it with this below: Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Intersect(Target, Me.Range("B2:B30")) Is Nothing Then If Target.Value 0 Then Target(1, 5).Value = Randomize(Rnd) Target(1, 7).Value = Randomize2(Rnd) End If If Target.Value = 0 Then Target(1, 5).Value = 0 Target(1, 7).Value = 0 End If End If Application.EnableEvents = True End Sub Now, if I want to highlight more then one cell in the range B2:B30, and paste something or delete the contents, I get the old Run-time error '13': Type mismatch. Does anyone know how to get around this? BTW, I was helped getting this formula from this disscussion group...you all are awesome at what you know. Thanks in advance -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Object hyperlink produces "Reference is not valid" error after worksheet name change | Excel Programming | |||
424 error on a Worksheet Change Macro | Excel Programming | |||
Change Cell from Validated List Not Firing Worksheet Change Event | Excel Programming | |||
worksheet change event error events disabled | Excel Programming | |||
Sorting a 2 column list with VBA using Worksheet change produces 1004 error | Excel Programming |