Here's the code that I am adding that causes Excel to crash. Note,
this is now in a Class Module... used to be just a module. Crashes
either way. Please let me know if you see anything here that looks
suspicious. Thank you.
Option Explicit
Private errMsgs As Range
Public errMsgsCount As Integer
Private errWorksheet As Worksheet
Public currentUsage As String
Private Const InputSheetName As String = "Input"
Public WorkbookToUpdateVer As String
Public SelectedPlanName As String
Public Function getfn() As Variant
Dim fileFilter As String
fileFilter = "Excel Files (*.xls), *.xls,CSV Files (*.csv),
*.csv,All Files (*.*), *.*"
getfn = Application.GetOpenFilename(fileFilter:=fileFilter,
Title:="Select File for Import")
End Function
Public Sub runImport(ByRef importInfo As ImportParams, ByVal
checkERISA As Boolean, ByVal checkFAS87 As Boolean, ByVal
checkFAS106WithSubsidy As Boolean, ByVal checkFAS106WithoutSubsidy As
Boolean, ByVal radioERISAtotal As Boolean, ByVal radioFAS87total As
Boolean, ByVal radioFAS106WithSubsidytotal As Boolean, ByVal
radioFAS106WithoutSubsidytotal As Boolean)
Dim saveUpdating As Boolean
Dim wbSummary As Workbook
ReDim cellArray(0 To 0, 0 To 0) As String 'array to hold all
information from the integration ws
ReDim errorArray(0 To 0) As String 'array to hold
warning and error messages
saveUpdating = Application.ScreenUpdating
Application.ScreenUpdating = False
'only process the usage that has been checked
If checkERISA = True Then
currentUsage = "ERISA"
If importInfo.bPPAApplies Then
'Run for post-PPA
Call copyCells(importInfo, cellArray, "ERISA PPA -
Valuation Year")
Call pasteERISAInputCells_2_00(importInfo, cellArray,
errorArray)
Call pasteERISACells_2_00(importInfo, cellArray,
errorArray)
Call pasteERISALiabCells_2_00(importInfo, cellArray,
errorArray, radioERISAtotal)
Else
'Run for pre-PPA
Call copyCells(importInfo, cellArray, "ERISA - Valuation
Year")
Call pasteERISAInputCells_1_10(importInfo, cellArray,
errorArray)
Call pasteERISACells_1_10(importInfo, cellArray,
errorArray)
Call pasteERISALiabCells_1_10(importInfo, cellArray,
errorArray, radioERISAtotal)
End If
End If
If checkFAS87 = True Then
currentUsage = "FAS87"
Call copyCells(importInfo, cellArray, "FAS87 - Valuation
Year")
Call pasteFAS87InputCells_1_10(importInfo, cellArray,
errorArray)
Call pasteFAS87Cells_1_10(importInfo, cellArray, errorArray)
Call pasteFAS87LiabCells_1_10(importInfo, cellArray,
errorArray, radioFAS87total)
End If
If checkFAS106WithSubsidy = True Or checkFAS106WithoutSubsidy =
True Then
currentUsage = "FAS106"
Call copyCells(importInfo, cellArray, "FAS106 - Valuation
Year")
Call pasteFAS106InputCells_1_10(importInfo, cellArray,
errorArray)
Call pasteFAS106Cells_1_10(importInfo, cellArray, errorArray)
Call pasteFAS106LiabCells_1_10(importInfo, cellArray,
errorArray, checkFAS106WithSubsidy, False,
radioFAS106WithSubsidytotal, radioFAS106WithoutSubsidytotal)
Call pasteFAS106LiabCells_1_10(importInfo, cellArray,
errorArray, False, checkFAS106WithoutSubsidy,
radioFAS106WithSubsidytotal, radioFAS106WithoutSubsidytotal)
End If
Call endProcessing(importInfo, errorArray)
Application.ScreenUpdating = saveUpdating
currentUsage = ""
End Sub
Public Function getImportParams(ByVal bPPAApplies As Boolean, ByVal
sIntegration_workBookName As String) As ImportParams
Dim importInfoLocal As ImportParams
importInfoLocal.sIntegration_workBookName =
sIntegration_workBookName
Set importInfoLocal.wIntegration_workbook = Nothing
importInfoLocal.bPPAApplies = bPPAApplies
getImportParams = importInfoLocal
End Function
Public Function validateFiles(ByRef importInfo As ImportParams) As
Boolean
Dim b As Boolean
validateFiles = True
'try to copy the WorkbookToUpdate file so as not to ruin the
original
' MDG 5/6/2008: Run from WorkbookToUpdate, no need to validate
WorkbookToUpdate file
' If Not saveWorkbook(importInfo) Then
' validateFiles = False
' Exit Function
' End If
'try to connect to the integration file and the newly created
WorkbookToUpdate file
b = Application.DisplayAlerts
Application.DisplayAlerts = False
On Error Resume Next
Set importInfo.wIntegration_workbook =
workBooks.Open(importInfo.sIntegration_workBookName)
If Not canActivate(importInfo.wIntegration_workbook) Then
MsgBox ("Unable to load " &
importInfo.sIntegration_workBookName)
Set importInfo.wIntegration_workbook = Nothing
validateFiles = False
End If
' Set WorkbookToUpdateworkbook =
workBooks.Open(WorkbookToUpdateworkbook.name)
' If Not canActivate(WorkbookToUpdateworkbook) Then
' MsgBox ("Unable to load " & WorkbookToUpdateworkbook.name)
' Set WorkbookToUpdateworkbook = Nothing
' validateFiles = False
' End If
Application.DisplayAlerts = b
On Error GoTo 0
End Function
Public Function canActivate(WB As Workbook) As Boolean
Dim save As Workbook
Set save = ActiveWorkbook
On Error GoTo ActivateFailed
WB.Activate
save.Activate
canActivate = True
On Error GoTo 0
Exit Function
ActivateFailed:
save.Activate
canActivate = False
End Function
Public Function canActivateWorksheet(wsname As String) As Boolean
Dim save As Worksheet
Set save = ActiveSheet
On Error GoTo ActivateFailed
Worksheets(wsname).Activate
save.Activate
canActivateWorksheet = True
On Error GoTo 0
Exit Function
ActivateFailed:
save.Activate
canActivateWorksheet = False
End Function
'Function copyCells
'This function populates cellArray with all information in the
WorkbookToUpdate integration
'workbook. This is done so that we do not have to constantly search
the workbook,
'we can just search the array. This is done so that we don't have as
many workbook
'activations.
Public Function copyCells(ByRef importInfo As ImportParams, ByRef
cellArray() As String, Worksheetname As String)
Dim maxRow As Integer, maxColumn As Integer
Dim row As Integer, column As Integer
Dim errorMsg As String
With importInfo.wIntegration_workbook
On Error GoTo ActivateFailed
maxRow = .Worksheets(Worksheetname).UsedRange.Rows.Count
maxColumn
= .Worksheets(Worksheetname).UsedRange.Columns.Count
ReDim cellArray(0 To maxRow, 0 To maxColumn)
.Worksheets(Worksheetname).Activate
With Range("A1:A1")
For row = 0 To maxRow
For column = 0 To maxColumn
cellArray(row, column) = .Offset(row,
column).Value
Next column
Next row
End With
On Error GoTo 0
End With
Exit Function
ActivateFailed:
errorMsg = "Cannot find worksheet " + Worksheetname
errorMsg = errorMsg + " in the file " +
importInfo.sIntegration_workBookName
MsgBox (errorMsg)
End Function
Public Function findRow(ByRef cellArray() As String, findString As
String, startRow As Integer) As Integer
Dim maxRow As Integer, row As Integer
Dim notFound As Boolean
notFound = True
row = startRow
maxRow = UBound(cellArray, 1)
Do While row <= maxRow And notFound = True
If (cellArray(row, 0) = findString) Then
notFound = False
Else
row = row + 1
End If
Loop
If notFound = True Then
row = -1
End If
findRow = row
End Function
'insertField function takes the following arguments
'errorArray is the array for error messages
'cellArray holds the values from the WorkbookToUpdate Integration
worksheet
'the paste worksheet name in WorkbookToUpdate
'the field to copy is sent to the insert function as a string
'the row offset for the paste location
'the column offset for the paste location is sent via an integer
'the column offset for the copy location
'the start row for the findRow function is an optional field
Public Function insertField(ByRef errorArray() As String, ByRef
cellArray() As String, fieldName As String, rowOffsetPaste As Integer,
colOffsetPaste As Integer, colOffsetCopy As Integer, Optional startRow
As Integer = 0, Optional errorOrWarning As Boolean = True) As Integer
Dim row As Integer
row = findRow(cellArray, fieldName, startRow)
With Range("A1:A1")
If row <> -1 Then
'MDG 5/6/2008: We allow non-numerical values to be
returned
'If IsNumeric(cellArray(row, colOffsetCopy)) Then
.Offset(rowOffsetPaste, colOffsetPaste) =
cellArray(row, colOffsetCopy)
'ElseIf errorOrWarning Then
' Call addWarningMessage(errorArray, "Warning: The
value: " + cellArray(row, colOffsetCopy) + " in the " + fieldName + "
field, is not numerical.")
'End If
'if field doesn't exist, print out warning message. Unfunded
fields are conditional and may not be in the file
'The second two field names may exist multiple times, we
search and paste until not found, we don't want to display an error
for the last loop when they aren't found
ElseIf errorOrWarning And (fieldName <> "Unfunded Old
Liability" And fieldName <> "Unfunded Old Liability Amount" _
And fieldName <> "PSC Unamortized
Amount" And fieldName <> "PSC Annual Amortization" _
And fieldName <> "Years Remaining"
And fieldName <> "Unamortized Amount") Then
Call addWarningMessage(errorArray, "Warning: The field: "
+ fieldName + " was not found in the Integration Worksheet.")
End If
End With
insertField = row
End Function
'Function to create an error worksheet in the WorkbookToUpdate file.
We will hide it at first
'so the user doesn't see it until the run is complete.
Public Sub createErrorWorksheet(ByRef importInfo As ImportParams)
On Error Resume Next
WorkbookToUpdateWorkbook.Worksheets("Import Errors").Delete
On Error GoTo 0
Dim saveUpdating As Boolean
saveUpdating = Application.ScreenUpdating
Application.ScreenUpdating = False
Set errWorksheet =
WorkbookToUpdateWorkbook.Worksheets.Add(before:=Sheets(1))
errWorksheet.Name = "Import Errors"
Application.ScreenUpdating = saveUpdating
End Sub
Public Function addWarningMessage(ByRef errorArray() As String,
errorMessage As String)
If Len(Trim(currentUsage)) > 0 Then errorMessage = "[" &
currentUsage & "] " + errorMessage
errorArray(errMsgsCount) = errorMessage
errMsgsCount = errMsgsCount + 1
ReDim Preserve errorArray(0 To errMsgsCount)
End Function
'Ending processing. If there are errors, display the error worksheet
and
'set it as the active sheet. If there are no errors, delete the error
worksheet
'If there are no errors,
Public Sub endProcessing(ByRef importInfo As ImportParams, ByRef
errorArray() As String)
Dim localErrCount As Integer
localErrCount = 0
If (errMsgsCount <> 0) Then
Call createErrorWorksheet(importInfo)
errWorksheet.Activate
With Range("A1:A1")
Do While localErrCount <= errMsgsCount
If (Left(errorArray(localErrCount), 5) = "Error") Then
.Offset(localErrCount).Font.Bold = True
End If
.Offset(localErrCount, 0) = errorArray(localErrCount)
localErrCount = localErrCount + 1
Loop
End With
Else
WorkbookToUpdateWorkbook.Worksheets("Client").Activate
End If
MsgBox ("Update Completed with " + CStr(errMsgsCount) + "
errors.")
Application.StatusBar = False
End Sub
'******************************************************************************
'WorkbookToUpdate 1.10 changes
'******************************************************************************
'The redesign effor to get rid of the hardcoded stuff turned out to be
too involved
'so untill WorkbookToUpdate is rewritten just do stupid copy paste
crap
Public Function pasteFAS87Cells_1_10(ByRef importInfo As ImportParams,
ByRef cellArray() As String, ByRef errorArray() As String)
Dim row As Integer
Dim Worksheetname As String
Worksheetname = "FAS" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID))
On Error GoTo ActivateFailed
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
On Error GoTo 0
Application.StatusBar = "Updating " + Worksheetname
Call insertField(errorArray, cellArray, _
"Average Future Service", 56, 5, 1)
Call insertField(errorArray, cellArray, _
"Corridor for gain/loss amortization", 57, 5, 1)
Call insertField(errorArray, cellArray, _
"Fair Value of Assets", 60, 5, 1)
Call insertField(errorArray, cellArray, _
"Market Related Value of Assets", 61, 5, 1)
' Call insertField(errorArray, cellArray, _
' "Prepaid Pension Cost", 80, 5, 1)
Call insertField(errorArray, cellArray, _
"ITO Unamortized Amount", 64, 5, 1)
Call insertField(errorArray, cellArray, _
"ITO Annual Amortization", 64, 6, 1)
Dim startRow As Integer, pscImportRow As Integer
row = 0
startRow = 0
pscImportRow = 67 'offset for the first PSC
Do While (row <> -1) 'loop to handle multiple prior
serv costs
row = insertField(errorArray, cellArray, _
"PSC Unamortized Amount", pscImportRow, 5, 1,
startRow)
row = insertField(errorArray, cellArray, _
"PSC Annual Amortization", pscImportRow, 6, 1,
startRow)
pscImportRow = pscImportRow + 1
startRow = row + 1
Loop
Exit Function
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname + "
does not exist in " + WorkbookToUpdateWorkbook)
End Function
Public Function pasteFAS87InputCells_1_10(ByRef importInfo As
ImportParams, ByRef cellArray() As String, ByRef errorArray() As
String)
Dim row As Integer
Dim Worksheetname As String
Worksheetname = "Input" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID))
On Error GoTo ActivateFailed
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
On Error GoTo 0
Application.StatusBar = "Updating " + Worksheetname
Call insertField(errorArray, cellArray, _
"Discount Rate", 3, 3, 1)
Call insertField(errorArray, cellArray, _
"Compensation increase - Male", 4, 3, 1)
Call insertField(errorArray, cellArray, _
"Crediting Rate", 5, 3, 1)
Call insertField(errorArray, cellArray, _
"Cost-of-living Adjustment - Post commencement", 6, 3, 1)
Call insertField(errorArray, cellArray, _
"Expected Return on Assets", 7, 3, 1)
Exit Function
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname + "
does not exist in " + WorkbookToUpdateWorkbook.Name)
End Function
Public Function pasteFAS87LiabCells_1_10(ByRef importInfo As
ImportParams, ByRef cellArray() As String, ByRef errorArray() As
String, ByVal radioFAS87total As Boolean)
Dim maxColumn As Integer
Dim row As Integer, reportBreak As Integer
Dim startColumn As Integer, endColumn As Integer
Dim Worksheetname As String
reportBreak = 1
maxColumn = UBound(cellArray, 2)
If maxColumn > 5 And Not radioFAS87total Then
Call addWarningMessage(errorArray, "WorkbookToUpdate 2.0 can
handle a maximum of 3 liability groups. Your integration workbook
contains " + Trim(maxColumn - 2) + "." +
WorkbookToUpdateWorkbook.Name)
Exit Function
End If
If (radioFAS87total = True) Then
startColumn = 1
endColumn = 1
Else
startColumn = 2
endColumn = maxColumn - 1
If (startColumn > endColumn) Then
Call addWarningMessage(errorArray, "Error: Import using
Report Breaks selected for FAS87, but no Report Breaks exist in " +
importInfo.sIntegration_workBookName)
End If
End If
Do While startColumn <= endColumn
Worksheetname = "FAS" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID)) + "-
liab" + CStr(reportBreak)
If Not (canActivateWorksheet(Worksheetname)) Then
GoTo ActivateFailed
Else
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
Application.StatusBar = "Updating " + Worksheetname
End If
Call insertField(errorArray, cellArray, _
"Total PBO", 40, 4, startColumn)
Call insertField(errorArray, cellArray, _
"Total ABO", 41, 4, startColumn)
Call insertField(errorArray, cellArray, _
"PBO service cost (gross)", 42, 4, startColumn)
Call insertField(errorArray, cellArray, _
"ABO service cost (gross)", 43, 4, startColumn)
Call insertField(errorArray, cellArray, _
"Expected benefit payments for year", 44, 4,
startColumn)
Call insertField(errorArray, cellArray, _
"Expected employee contributions for year", 45, 4,
startColumn)
GoTo NextColumn
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname +
" does not exist in " + WorkbookToUpdateWorkbook.Name)
NextColumn:
startColumn = startColumn + 1
reportBreak = reportBreak + 1
Loop
End Function
Public Function pasteFAS106Cells_1_10(ByRef importInfo As
ImportParams, ByRef cellArray() As String, ByRef errorArray() As
String)
Dim row As Integer
Dim Worksheetname As String
Worksheetname = "FAS" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID))
On Error GoTo ActivateFailed
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
On Error GoTo 0
Application.StatusBar = "Updating " + Worksheetname
Call insertField(errorArray, cellArray, _
"Average Future Service", 52, 5, 1)
Call insertField(errorArray, cellArray, _
"Corridor for gain/loss amortization", 53, 5, 1)
Call insertField(errorArray, cellArray, _
"AFS to Full Eligibility Age", 55, 5, 1)
Call insertField(errorArray, cellArray, _
"Fair Value of Assets", 58, 5, 1)
Call insertField(errorArray, cellArray, _
"Market Related Value of Assets", 59, 5, 1)
' Call insertField(errorArray, cellArray, _
' "Prepaid Pension Cost", 78, 5, 1)
Call insertField(errorArray, cellArray, _
"ITO Unamortized Amount", 62, 5, 1)
Call insertField(errorArray, cellArray, _
"ITO Annual Amortization", 62, 6, 1)
Dim startRow As Integer, pscImportRow As Integer
row = 0
startRow = 0
pscImportRow = 65 'offset for the first PSC
Do While (row <> -1) 'loop to handle multiple prior
serv costs
row = insertField(errorArray, cellArray, _
"PSC Unamortized Amount", pscImportRow, 5, 1,
startRow)
row = insertField(errorArray, cellArray, _
"PSC Annual Amortization", pscImportRow, 6, 1,
startRow)
pscImportRow = pscImportRow + 1
startRow = row + 1
Loop
Exit Function
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname + "
does not exist in " + WorkbookToUpdateWorkbook.Name)
End Function
Public Function pasteFAS106InputCells_1_10(ByRef importInfo As
ImportParams, ByRef cellArray() As String, ByRef errorArray() As
String)
Dim row As Integer
Dim Worksheetname As String
Worksheetname = "Input" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID))
On Error GoTo ActivateFailed
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
On Error GoTo 0
Application.StatusBar = "Updating " + Worksheetname
Call insertField(errorArray, cellArray, _
"Discount Rate", 3, 3, 1)
Call insertField(errorArray, cellArray, _
"Compensation increase - Male", 4, 3, 1)
Call insertField(errorArray, cellArray, _
"Expected Return on Assets", 7, 3, 1)
Call insertField(errorArray, cellArray, _
"Trend rate: initial", 8, 3, 1)
Call insertField(errorArray, cellArray, _
"Trend rate: ultimate", 9, 3, 1)
Call insertField(errorArray, cellArray, _
"Annual decrease", 10, 3, 1)
Exit Function
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname + "
does not exist in " + WorkbookToUpdateWorkbook.Name)
End Function
Public Function pasteFAS106LiabCells_1_10(ByRef importInfo As
ImportParams, ByRef cellArray() As String, ByRef errorArray() As
String, ByRef processingWithSubsidy As Boolean, ByRef
processingWithoutSubsidy As Boolean, ByVal radioFAS106WithSubsidytotal
As Boolean, ByVal radioFAS106WithoutSubsidytotal As Boolean)
Dim maxColumn As Integer
Dim row As Integer, reportBreak As Integer
Dim startColumn As Integer, endColumn As Integer
Dim Worksheetname As String
reportBreak = 1
maxColumn = UBound(cellArray, 2)
If maxColumn > 5 And ((processingWithSubsidy And Not
radioFAS106WithSubsidytotal) Or (processingWithoutSubsidy And Not
radioFAS106WithoutSubsidytotal)) Then
Call addWarningMessage(errorArray, "WorkbookToUpdate 2.0 can
handle a maximum of 3 liability groups. Your integration workbook
contains " + Trim(maxColumn - 2) + "." +
WorkbookToUpdateWorkbook.Name)
Exit Function
End If
If (processingWithSubsidy = True) Then
If (radioFAS106WithSubsidytotal = True) Then
startColumn = 1
endColumn = 1
ElseIf (radioFAS106WithSubsidytotal = False) Then
startColumn = 2
endColumn = maxColumn - 1
If (startColumn > endColumn) Then
Call addWarningMessage(errorArray, "Error: Import
using Report Breaks selected for FAS106 With Subsidy, but no Report
Breaks exist in " + importInfo.sIntegration_workBookName)
End If
End If
End If
If (processingWithoutSubsidy = True) Then
If (radioFAS106WithoutSubsidytotal = True) Then
startColumn = 1
endColumn = 1
ElseIf (radioFAS106WithoutSubsidytotal = False) Then
startColumn = 2
endColumn = maxColumn - 1
If (startColumn > endColumn) Then
Call addWarningMessage(errorArray, "Error: Import
using Report Breaks selected for FAS106 Without Subsidy, but no Report
Breaks exist in " + importInfo.sIntegration_workBookName)
End If
End If
End If
Do While (startColumn >= 1) And (startColumn <= endColumn)
Worksheetname = "FAS" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID)) + "-
liab" + CStr(reportBreak)
If Not (canActivateWorksheet(Worksheetname)) Then
GoTo ActivateFailed
Else
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
Application.StatusBar = "Updating " + Worksheetname
End If
Call insertField(errorArray, cellArray, _
"Employer APBO Total", 35, 4, startColumn)
Call insertField(errorArray, cellArray, _
"Service cost", 36, 4, startColumn)
Call insertField(errorArray, cellArray, _
"Expected benefit payments for year", 37, 4,
startColumn)
GoTo NextColumn
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname +
" does not exist in " + WorkbookToUpdateWorkbook.Name)
NextColumn:
startColumn = startColumn + 1
reportBreak = reportBreak + 1
Loop
End Function
Public Function pasteERISACells_1_10(ByRef importInfo As ImportParams,
ByRef cellArray() As String, ByRef errorArray() As String)
Dim row As Integer
Dim Worksheetname As String
Worksheetname = "USOld" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID))
On Error GoTo ActivateFailed
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
On Error GoTo 0
Application.StatusBar = "Updating " + Worksheetname
Call insertField(errorArray, cellArray, _
"Market value of assets", 58, 5, 1)
Call insertField(errorArray, cellArray, _
"Actuarial value of assets", 59, 5, 1)
Call insertField(errorArray, cellArray, _
"Credit Balance/(Deficiency)", 62, 5, 1)
Call insertField(errorArray, cellArray, _
"Accumulated Reconciliation Account", 63, 5, 1)
Call insertField(errorArray, cellArray, _
"Unfunded Old Liability", 98, 5, 1)
Call insertField(errorArray, cellArray, _
"Unfunded Old Liability Amount", 99, 5, 1)
Dim startRow As Integer, fsaImportRow As Integer
row = 0
startRow = 0
fsaImportRow = 66 'offset for the first FSA base
Do While (row <> -1) 'loop to handle multiple fsa bases
row = insertField(errorArray, cellArray, _
"Unamortized Amount", fsaImportRow, 6, 1, startRow)
row = insertField(errorArray, cellArray, _
"Years Remaining", fsaImportRow, 5, 1, startRow)
fsaImportRow = fsaImportRow + 1
startRow = row + 1
Loop
Exit Function
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname + "
does not exist in " + WorkbookToUpdateWorkbook.Name)
End Function
Public Function pasteERISACells_2_00(ByRef importInfo As ImportParams,
ByRef cellArray() As String, ByRef errorArray() As String)
Dim row As Integer
Dim Worksheetname As String
Worksheetname = "USPPA" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID))
On Error GoTo ActivateFailed
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
On Error GoTo 0
Application.StatusBar = "Updating " + Worksheetname
Call insertField(errorArray, cellArray, _
"Market value of assets", 102, 5, 1)
Call insertField(errorArray, cellArray, _
"Actuarial value of assets", 103, 5, 1)
Call insertField(errorArray, cellArray, _
"Present Value of Contributions receivable", 104, 5, 1)
Call insertField(errorArray, cellArray, _
"Funding Standard Carryover Balance", 105, 5, 1)
Call insertField(errorArray, cellArray, _
"Prefunding Balance", 106, 5, 1)
Call insertField(errorArray, cellArray, _
"Reflect Phase-In Provisions for Applicable Percentages?",
107, 5, 1)
Call insertField(errorArray, cellArray, _
"Prior Year Minimum Contribution", 111, 5, 1)
Call insertField(errorArray, cellArray, _
"Funded Ratio for Quarterly Contributions and At-Risk
status", 112, 5, 1)
Call insertField(errorArray, cellArray, _
"Funded Ratio for Eligibility to Apply Balances", 113, 5,
1)
Call insertField(errorArray, cellArray, _
"Prior Year AVA", 114, 5, 1)
Call insertField(errorArray, cellArray, _
"Prior Year Ongoing Liability", 115, 5, 1)
Call insertField(errorArray, cellArray, _
"Prior Year Prefunding Balance", 116, 5, 1)
Call insertField(errorArray, cellArray, _
"Eligibility for transition percentages for exemption from
new SAB", 117, 5, 1)
Exit Function
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname + "
does not exist in " + WorkbookToUpdateWorkbook.Name)
End Function
Public Function pasteERISAInputCells_1_10(ByRef importInfo As
ImportParams, ByRef cellArray() As String, ByRef errorArray() As
String)
Dim row As Integer
Dim Worksheetname As String
Worksheetname = "Input" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID))
On Error GoTo ActivateFailed
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
On Error GoTo 0
Application.StatusBar = "Updating " + Worksheetname
Call insertField(errorArray, cellArray, _
"Interest rate", 33, 3, 1)
Call insertField(errorArray, cellArray, _
"Compensation Increase - male", 34, 3, 1)
Call insertField(errorArray, cellArray, _
"Crediting Rate", 35, 3, 1)
Call insertField(errorArray, cellArray, _
"Current liability rate for min", 37, 3, 1)
Call insertField(errorArray, cellArray, _
"Top of CL range for min", 38, 3, 1)
'Call insertField(errorArray, cellArray, _
"Current liability rate for max", 19, 3, 1)
Call insertField(errorArray, cellArray, _
"PBGC required interest rate", 40, 3, 1)
Exit Function
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname + "
does not exist in " + WorkbookToUpdateWorkbook.Name)
End Function
Public Function pasteERISAInputCells_2_00(ByRef importInfo As
ImportParams, ByRef cellArray() As String, ByRef errorArray() As
String)
Dim row As Integer
Dim Worksheetname As String
Worksheetname = "Input" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID))
On Error GoTo ActivateFailed
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
On Error GoTo 0
Application.StatusBar = "Updating " + Worksheetname
Call insertField(errorArray, cellArray, _
"Effective Interest Rate", 33, 3, 1)
' Call insertField(errorArray, cellArray, _
' "Year 1 Discount Rate", 33, 4, 1)
' Call insertField(errorArray, cellArray, _
' "Year 2 Discount Rate", 33, 5, 1)
' Call insertField(errorArray, cellArray, _
' "Year 3 Discount Rate", 33, 6, 1)
' Call insertField(errorArray, cellArray, _
' "Year 4 Discount Rate", 33, 7, 1)
' Call insertField(errorArray, cellArray, _
' "Year 5 Discount Rate", 33, 8, 1)
' Call insertField(errorArray, cellArray, _
' "Year 6 Discount Rate", 33, 9, 1)
' Call insertField(errorArray, cellArray, _
' "Year 7 Discount Rate", 33, 10, 1)
Call insertField(errorArray, cellArray, _
"Compensation Increase - male", 34, 3, 1)
Call insertField(errorArray, cellArray, _
"Crediting Rate", 35, 3, 1)
Exit Function
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname + "
does not exist in " + WorkbookToUpdateWorkbook.Name)
End Function
Public Function pasteERISALiabCells_1_10(ByRef importInfo As
ImportParams, ByRef cellArray() As String, ByRef errorArray() As
String, ByVal radioERISAtotal As Boolean)
Dim maxColumn As Integer
Dim row As Integer, reportBreak As Integer
Dim startColumn As Integer, endColumn As Integer
Dim Worksheetname As String
reportBreak = 1
maxColumn = UBound(cellArray, 2)
If maxColumn > 5 And Not radioERISAtotal Then
Call addWarningMessage(errorArray, "WorkbookToUpdate 2.0 can
handle a maximum of 3 liability groups. Your integration workbook
contains " + Trim(maxColumn - 2) + "." +
WorkbookToUpdateWorkbook.Name)
Exit Function
End If
If (radioERISAtotal = True) Then
startColumn = 1
endColumn = 1
Else
startColumn = 2
endColumn = maxColumn - 1
If (startColumn > endColumn) Then
Call addWarningMessage(errorArray, "Error: Import using
Report Breaks selected for ERISA, but no Report Breaks exist in " +
importInfo.sIntegration_workBookName)
End If
End If
Do While startColumn <= endColumn
Worksheetname = "USOld" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID)) + "-
liab" + CStr(reportBreak)
'check to see if the liab worksheet exists
If Not (canActivateWorksheet(Worksheetname)) Then
GoTo ActivateFailed
Else
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
Application.StatusBar = "Updating " + Worksheetname
End If
Dim retVal As Integer
Call insertField(errorArray, cellArray, _
"AAL - Total", 44, 4, startColumn)
Call insertField(errorArray, cellArray, _
"Normal Cost - AAL", 45, 4, startColumn)
Call insertField(errorArray, cellArray, _
"Present Value of Benefits - Total", 46, 4,
startColumn)
Call insertField(errorArray, cellArray, _
"Temporary Annuity Factor (TAF)", 47, 4, startColumn)
Call insertField(errorArray, cellArray, _
"RPA CL - Total", 48, 4, startColumn)
Call insertField(errorArray, cellArray, _
"RPA '94 Current Liability Normal Cost", 49, 4,
startColumn)
Call insertField(errorArray, cellArray, _
"Top-of-range CL for min - Total", 50, 4, startColumn)
'Call insertField(errorArray, cellArray, _
"Current Liability for Max - Total", 51, 4,
startColumn)
'Call insertField(errorArray, cellArray, _
"Current Liability Normal Cost for max", 33, 4,
startColumn)
'If insertField(errorArray, cellArray, "Expected Benefit
Payments", 34, 4, startColumn, , False) = -1 Then
Call insertField(errorArray, cellArray, _
"Expected Benefit Payments - AAL, OBRA '87", 51,
4, startColumn)
'End If
Call insertField(errorArray, cellArray, _
"Expected Benefit Payments - RPA '94", 52, 4,
startColumn)
Call insertField(errorArray, cellArray, _
"PBGC - Total", 53, 4, startColumn)
GoTo NextColumn
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname +
" does not exist in " + WorkbookToUpdateWorkbook.Name)
NextColumn:
startColumn = startColumn + 1
reportBreak = reportBreak + 1
Loop
End Function
Public Function pasteERISALiabCells_2_00(ByRef importInfo As
ImportParams, ByRef cellArray() As String, ByRef errorArray() As
String, ByVal radioERISAtotal As Boolean)
Dim maxColumn As Integer
Dim row As Integer, reportBreak As Integer
Dim startColumn As Integer, endColumn As Integer
Dim Worksheetname As String
reportBreak = 1
maxColumn = UBound(cellArray, 2)
If maxColumn > 5 And Not radioERISAtotal Then
Call addWarningMessage(errorArray, "WorkbookToUpdate 2.0 can
handle a maximum of 3 liability groups. Your integration workbook
contains " + Trim(maxColumn - 2) + "." +
WorkbookToUpdateWorkbook.Name)
Exit Function
End If
If (radioERISAtotal = True) Then
startColumn = 1
endColumn = 1
Else
startColumn = 2
endColumn = maxColumn - 1
If (startColumn > endColumn) Then
Call addWarningMessage(errorArray, "Error: Import using
Report Breaks selected for ERISA, but no Report Breaks exist in " +
importInfo.sIntegration_workBookName)
End If
End If
Do While startColumn <= endColumn
Worksheetname = "USPPA" +
Trim(getPlanInfoFromIndex(SelectedPlanName, INDEXCOL_TEMPLATEID)) + "-
liab" + CStr(reportBreak)
'check to see if the liab worksheet exists
If Not (canActivateWorksheet(Worksheetname)) Then
GoTo ActivateFailed
Else
WorkbookToUpdateWorkbook.Worksheets(Worksheetname).Activate
Application.StatusBar = "Updating " + Worksheetname
End If
Dim retVal As Integer
Call insertField(errorArray, cellArray, _
"Target - Total", 46, 4, startColumn)
Call insertField(errorArray, cellArray, _
"Target Normal Cost", 47, 4, startColumn)
Call insertField(errorArray, cellArray, _
"At-Risk - Total", 48, 4, startColumn)
Call insertField(errorArray, cellArray, _
"At-Risk Normal Cost", 49, 4, startColumn)
Call insertField(errorArray, cellArray, _
"PUC Funding Target - Total", 50, 4, startColumn)
Call insertField(errorArray, cellArray, _
"At-Risk PBGC - Total", 52, 4, startColumn)
Call insertField(errorArray, cellArray, _
"Ongoing PBGC - Total", 51, 4, startColumn)
Call insertField(errorArray, cellArray, _
"Expected Benefit Payments", 53, 4, startColumn)
GoTo NextColumn
ActivateFailed:
Call addWarningMessage(errorArray, "Error: " + Worksheetname +
" does not exist in " + WorkbookToUpdateWorkbook.Name)
NextColumn:
startColumn = startColumn + 1
reportBreak = reportBreak + 1
Loop
End Function
Public Function getPlanInfoFromIndex(ByVal sPlanName As String, ByVal
iCol As Integer) As Long
Dim IndexTable As Range, row As Range
Set IndexTable = ThisWorkbook.Names("IndexTable").RefersToRange
For Each row In IndexTable.Rows
If row.Cells(1, 1).Value = "" Then
Exit Function
End If
If UCase(row.Cells(1, 1).Value) = UCase(sPlanName) Then
getPlanInfoFromIndex = cvLng(row.Cells(1, iCol).Value)
End If
Next row
End Function