danners430
New Member
- Joined
- Aug 3, 2017
- Messages
- 45
Hey guys
I've got a troublesome spreadsheet where strange things happen when the worksheet.change event is supposed to fire...
The worksheet has a large table in it, using Excel's built in table functionality.
The event, of course, should always fire when a cell is altered - but in this sheet, it only fires under the following circumstances:
1. When a value outside of the main table is deleted
2. When a value in column 10 is deleted
3. When a value of the correct length is entered into column 10 - except here it doesn't show the macro running when breaks are added to the code - it just does it.
Unfortunately, I can't upload the spreadsheet, but I can upload the code (albeit very slightly edited). here it is:
In module 1 (conditional formatting functions):
I've tried all the usual suspects,
At this point I'm at a loss... anyone got any ideas?
I've got a troublesome spreadsheet where strange things happen when the worksheet.change event is supposed to fire...
The worksheet has a large table in it, using Excel's built in table functionality.
The event, of course, should always fire when a cell is altered - but in this sheet, it only fires under the following circumstances:
1. When a value outside of the main table is deleted
2. When a value in column 10 is deleted
3. When a value of the correct length is entered into column 10 - except here it doesn't show the macro running when breaks are added to the code - it just does it.
Unfortunately, I can't upload the spreadsheet, but I can upload the code (albeit very slightly edited). here it is:
Code:
Option ExplicitDim ChangeDis As Boolean
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If ChangeDis = True Then Exit Sub
ChangeDis = True
If Target.Column = 10 Then
If Target.Cells <> "" And Len(Target.Cells.Value) = 3 And IsNumeric(Target.Cells.Value) = True Then
Cells(Target.Row + 1, 1).Activate
Cells(Target.Row, 10) = "XXX-1000004" & Cells(Target.Row, 10).Value
End If
ElseIf Target.Column = 2 Then
If Target.Cells <> "" Then Cells(Target.Row, 4).Activate
End If
ChangeDis = False
End Sub
In module 1 (conditional formatting functions):
Code:
Option Explicit
Public Function Difference(Row As Integer)
Application.Volatile
If Cells(Row, 2) <> Cells(Row, 3) Then
Difference = "Limit Error"
ElseIf Cells(Row, 8) = "" Then
Difference = "No Values"
ElseIf Cells(Row, 8) = Cells(Row, 2) Or Cells(Row, 8) = Cells(Row, 3) Then
Difference = 0
ElseIf IsNumeric(Cells(Row, 8)) = True Then
Difference = Cells(Row, 8).Value - Cells(Row, 2).Value
Else
Difference = "Error"
End If
End Function
Public Function CheckNumeracy(Value) As Boolean
Application.Volatile
If IsNumeric(Value) = True Then
CheckNumeracy = True
Else
CheckNumeracy = False
End If
End Function
I've tried all the usual suspects,
Code:
application.enableevents = true
application.screenupdating = true
application.dataentrymode = false
Last edited: