Ironman
Well-known Member
- Joined
- Jan 31, 2004
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi
The below code was kindly provided to me by somebody on the board many years ago and the layout of the relevant sheet has changed since then.
Following changes to the worksheet some years ago I believe the below line is causing the workbook to hang because the range is now meaningless.
The objective of the code is on double clicking any cell in Column G from row 12 to say row 20000 (I'm down to row 6800 at the moment) and NO OTHER CELLS then a msgbox with a cumulative value in it is produced. This runs OK but Excel frequently hangs if I happen to double click cells in other columns and I'm hoping it's because of the above range being incorrect.
I'd be grateful for some help to amend the range and hopefully eliminate the hanging issue.
Many thanks.
The below code was kindly provided to me by somebody on the board many years ago and the layout of the relevant sheet has changed since then.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 7 Then
TopCell = Cells(12, 3).Address
BottomCell = Cells(ActiveCell.Row, 3).Address
TotalCalc = Application.WorksheetFunction.Sum(Range(TopCell, BottomCell))
MsgBox "Total miles run to " & Format(Cells(ActiveCell.Row, 1), "dd mmmm yyyy: ") & _
Format((CLng(10720.31 + TotalCalc)), "#,##0") & " ", vbOKOnly, "Lifetime Mileage"
End If
If Not Application.Intersect(Range("A8:C9"), Range(Target.Address)) Is Nothing Then
End If
End Sub
Following changes to the worksheet some years ago I believe the below line is causing the workbook to hang because the range is now meaningless.
Code:
If Not Application.Intersect(Range("A8:C9"), Range(Target.Address)) Is Nothing Then
End If
The objective of the code is on double clicking any cell in Column G from row 12 to say row 20000 (I'm down to row 6800 at the moment) and NO OTHER CELLS then a msgbox with a cumulative value in it is produced. This runs OK but Excel frequently hangs if I happen to double click cells in other columns and I'm hoping it's because of the above range being incorrect.
I'd be grateful for some help to amend the range and hopefully eliminate the hanging issue.
Many thanks.
Last edited: