LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Code with formula interfering in worksheet change event

Here's the other code. By restrict, I meant that the code below
doesn't work when the above code is in the sheet event. The code below
puts the value of cells in the last column (range is AbbNames) equal to
the cells in column 10 (range Abbreviated), and then updates any
changed values on another sheet, Schedules.

On Error GoTo errHandler

If Target.Count 1 Then Exit Sub

On Error Resume Next
Set rng = Target.Dependents
On Error GoTo 0
If Not rng Is Nothing Then
Set rng1 = Union(rng, Target)
Else
Set rng1 = Target
End If

On Error GoTo errHandler

If Not Application.Intersect(rng1, _
Application.Range("Abbreviated")) Is Nothing Then
strOld = Target.EntireRow.Range("IV1").Value
strNew = Target.EntireRow.Range("J1").Value

Application.EnableEvents = False
Application.ScreenUpdating = False

Application.Range("AbbNames").Value = _
Application.Range("Abbreviated").Value
End If


Set wsData = Worksheets("Schedules")

On Error GoTo errHandler

Set myRange = wsData.Range("Students")
For Each mycell In myRange
If mycell.Value = "" Then
Else
If strOld < strNew And strOld < "" Then

Application.EnableEvents = False
Application.ScreenUpdating = False

wsData.Range("Students").Replace What:=strOld, _
Replacement:=strNew, LookAt:=xlPart, _
SearchOrder:=xlByRows

End If
End If
Next

Application.Range("AbbNames").Value = _
Application.Range("Abbreviated").Value

errHandler:

Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic

If Err.Number < 0 Then _
MsgBox "Error occured " & Err.Number & vbNewLine & _
Err.Description

exitHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic

Exit Sub

End Sub

 
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
Cell value change to trigger macro (worksheet change event?) Neil Goldwasser Excel Programming 4 January 10th 06 01:55 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM
Enable/Disable Worksheet Change Event code Stuart[_5_] Excel Programming 2 November 3rd 03 07:22 PM
Copy Sheets minus Worksheet Change Event code & Macro Buttons Bob[_36_] Excel Programming 0 October 8th 03 01:17 AM


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