Here's the code that I'm working on.
With application.calculate commented, the code works fine. Otherwise, on occasions it generates the error.
This is mind boggling.
Sub T3EditStart_T3Edit()
Dim iInitialCalc As Integer
Dim ws As Worksheet
Dim iActiveProject As Integer
Dim iGenInputs As Integer, iCostBenefit As Integer, iSIC As Integer, iPCT As Integer, iRA As Integer
Dim iHeightImpact As Integer, iWidthImpact As Integer, iHeightPCT As Integer, iHeightRisk As Integer, iHeightCrit As Integer
Dim iHeightC As Integer
Dim rngDummy1 As Range, rngDummy2 As Range
Application.Calculate
If Range("T3Start_ProjNum").Value = 0 Or Not IsNumeric(Range("T3Start_ProjNum").Value) Then
MsgBox "Please select a project", vbOKOnly, "Select Project"
Else
Call Disable(iInitialCalc)
iActiveProject = Range("T3Start_ProjNum").Value
With Tier3Edit
.Visible = xlSheetVisible
.Activate
.Cells(1, 1).Value = iActiveProject
End With
iGenInputs = Range("T3General_Inputs").Count
iCostBenefit = Range("T3CostBenefit").Count
iSIC = Range("T3Score_SIC").Count
iPCT = Range("T3Score_PCTSum").Count
iRA = Range("T3Score_RASum").Count
Tier3PCT.Visible = xlSheetVisible: iHeightPCT = Range("T3Score_PCT").Count
Tier3Risk.Visible = xlSheetVisible: iHeightRisk = Range("T3Score_Risk").Count
Tier3Impact.Visible = xlSheetVisible
iHeightImpact = Range("T3Score_Impact").Rows.Count
iWidthImpact = Range("T3Score_Impact").Columns.Count
iHeightCrit = Range("T3Score_Criticality").Count
iHeightC = Range("DB1_End").Row - Range("DB1_Start").Row
'Import General Inputs
Set rngDummy1 = Range("DB1AssociatedPortfolio").Offset(iActiveProject)
Set rngDummy2 = rngDummy1.Offset(0, iGenInputs - 1)
Range(rngDummy1, rngDummy2).Copy
Range("T3General_Inputs").Item(1).PasteSpecial Paste:=xlPasteValues, Transpose:=True
'Import Cost & Benefits
Set rngDummy1 = Range("DB1Benefits").Offset(iActiveProject)
Set rngDummy2 = rngDummy1.Offset(0, iCostBenefit - 1)
Range(rngDummy1, rngDummy2).Copy
Range("T3CostBenefit").Item(1).PasteSpecial Paste:=xlPasteValues, Transpose:=True
'Import SIC
Set rngDummy1 = Range("DB1SIC").Offset(iActiveProject)
Set rngDummy2 = rngDummy1.Offset(0, iSIC - 1)
Range(rngDummy1, rngDummy2).Copy
Range("T3Score_SIC").Item(1).PasteSpecial Paste:=xlPasteValues, Transpose:=True
'Import PCT
Set rngDummy1 = Range("DB2Score_PCT").Offset(1, iActiveProject - 1)
Set rngDummy2 = rngDummy1.Offset(iHeightPCT - 1)
Range(rngDummy1, rngDummy2).Copy
Range("T3Score_PCT").Item(1).PasteSpecial Paste:=xlPasteFormulas
'Import Capacity
Range("DB1_Impact").Offset((iHeightC + 1) * (iActiveProject - 1)).Copy
Range("T3Score_Impact").PasteSpecial Paste:=xlPasteValues
Tier3Start.Visible = xlSheetHidden
Application.CutCopyMode = False
Call Enable(iInitialCalc)
End If
End Sub
Bookmarks