Ironman
Well-known Member
- Joined
- Jan 31, 2004
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi
I am 100% certain that something in the below code is causing my worksheet to hang when I double click on a cell or when I run a macro affecting this sheet - there are NO VBA errors. Unfortunately the code was written for me around 15 years ago, so I can't go back to the author to query it.
I know there is nothing wrong with the functionality of the code because it performs the required function exactly as it should.
Here's the code:
I'm happy to post my workbook to Dropbox if this helps you, although I think the amendment(s) should be fairly straightforward for someone with a good knowledge of writing VBA, which is something I don't have.
I would be IMMENSELY grateful for a solution to this.
Thank you.
I am 100% certain that something in the below code is causing my worksheet to hang when I double click on a cell or when I run a macro affecting this sheet - there are NO VBA errors. Unfortunately the code was written for me around 15 years ago, so I can't go back to the author to query it.
I know there is nothing wrong with the functionality of the code because it performs the required function exactly as it should.
Here's the code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
CALC = Application.Calculation
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False
'This procedure updates the chart for the last 90 days' entries:
'Call UpdateLast90Days(Target)
Application.Calculation = CALC
Application.Calculate
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Sub UpdateLast90Days(Target As Range)
'This updates the Last 90 Runs chart:
Dim X1 As Range
Dim Tmp()
If Target.Cells.Count > 1 Then GoTo en
LastEntry = Range("A20000").End(xlUp).Row
Set ISECT = Application.Intersect(Target, Range("A" & LastEntry - 90 & ":E" & LastEntry))
Set ISECT1 = Application.Intersect(Target, Range("A12:E" & LastEntry))
If Not (ISECT Is Nothing) And Not (ISECT1 Is Nothing) Then
If AllFilled(Target) Then
Ans = MsgBox("Route: " & (Range("B" & Target.Row) & Chr(13) & Chr(13) & _
"Date: " & Format(Range("A" & Target.Row), "dddd dd mmmm yyyy") & Chr(13) _
& "Miles: " & Range("C" & Target.Row) & Chr(13) _
& "Pace: " & Range("E" & Target.Row).Text & " min/mile " & Chr(13) & Chr(13) & _
"Update Last 90 Days Running Chart now?"), vbOKCancel + vbQuestion, "New Training Log Entry")
If Ans = vbCancel Then
MsgBox "Last 90 Days Running Chart NOT updated", vbExclamation, "Last 90 Days Running Chart Update"
GoTo en
End If
Else: GoTo en
End If
Last = Worksheets("Training Log").Range("A20000").End(xlUp).Row + 1
FIRST = Last - 90
Set X1 = Worksheets("Training Log").Range("A" & FIRST & ":A" & Last)
Tmp = X1.Value
Worksheets("90R Data").Range("A2:A91") = Tmp
Set X1 = Worksheets("Training Log").Range("C" & FIRST & ":C" & Last)
Tmp = X1.Value
Worksheets("90R Data").Range("B2:B91") = Tmp
Set X1 = Worksheets("Training Log").Range("E" & FIRST & ":E" & Last)
Tmp = X1.Value
Worksheets("90R Data").Range("C2:C91") = Tmp
For Each c In Worksheets("90R Data").Range("C2:C91")
c.Value = c.Value * 24 * 60
Next c
Application.Calculate
Chart9.SeriesCollection(1).Values = Worksheets("90R Data").Range("H2:H91")
Chart9.SeriesCollection(2).Values = Worksheets("90R Data").Range("I2:I91")
MsgBox "Last 90 Days Running Chart updated successfully", vbInformation, "Last 90 Days Running Chart Update"
ElseIf Not (ISECT1 Is Nothing) Then
Dim LatestEntry As String
LatestEntry = Range("A" & LastEntry).Value
MsgBox "The entry you tried to edit is more than 90 days" & vbNewLine & "from the most recent entry (" & LatestEntry & ")" & _
" " & Chr(13) & Chr(13) & _
"Last 90 Days Running Chart NOT updated", vbInformation, "Data Beyond Last 90 Days"
End If
en:
DoEvents
End Sub
I'm happy to post my workbook to Dropbox if this helps you, although I think the amendment(s) should be fairly straightforward for someone with a good knowledge of writing VBA, which is something I don't have.
I would be IMMENSELY grateful for a solution to this.
Thank you.
Last edited: