I am using Excel 2016 32-bit and Excel 2019 32-bit. In both Excel versions, programmatic assigns halt VBA execution without any message.
Trust Center settings are set to Enable all Macros and Trust the access to the VBA Project Model.
The calculations work and are correct.
The code I am working with is below. Execution halts when the value of the LL95 variable is assigned to a cell. At this point VBA halts without any message.
' Compute 95%, 85% and 75% Confidence Intervals
Public Sub ConfidenceIntervals(topInputRow As Integer, bottomInputRow As Integer, outputRow As Integer)
Dim avg As Double
Dim sd As Double
Dim n As Double
Dim LL95 As Double
Dim UL95 As Double
Dim LL85 As Double
Dim UL85 As Double
Dim LL75 As Double
Dim UL75 As Double
Dim intervalRange As Range
Dim rangeString As String
n = CDbl(bottomInputRow - topInputRow)
rangeString = "C" & CStr(topInputRow) & ":C" & CStr(bottomInputRow)
Set intervalRange = Worksheets("Samples").Range(rangeString)
avg = WorksheetFunction.Average(intervalRange)
sd = WorksheetFunction.StDev_S(intervalRange)
' 95% Confidence Intervals
LL95 = Exp(avg - sd * 2.2622 / Sqr(n))
UL95 = Exp(avg + sd * 2.2622 / Sqr(n))
' 85% Confidence Intervals
LL85 = Exp(avg - sd * 1.5737 / Sqr(n))
UL85 = Exp(avg + sd * 1.5737 / Sqr(n))
' 75% Confidence Intervals
LL75 = Exp(avg - sd * 1.2297 / Sqr(n))
UL75 = Exp(avg + sd * 1.2297 / Sqr(n))
' Write the intervals to the output row.
Sheets("Samples").Select
Cells(outputRow, 7).Value = LL95
Cells(outputRow, 8).Value = UL95
Cells(outputRow, 9).Value = LL85
Cells(outputRow, 10).Value = UL85
Cells(outputRow, 11).Value = LL75
Cells(outputRow, 12).Value = UL75
End Sub
- I tried the following code to assign values. However, this produces the same behavior. VBA bombs with no message on the
Rng.Value = LL95
.
Dim Rng As Range
Set Rng = Sheets("Samples").Cells(outputRow, 7)
Rng.Value = LL95
Set Rng = Sheets("Samples").Cells(outputRow, 8)
Rng.Value = UL95
Set Rng = Sheets("Samples").Cells(outputRow, 9)
Rng.Value = LL85
Set Rng = Sheets("Samples").Cells(outputRow, 10)
Rng.Value = UL85
Set Rng = Sheets("Samples").Cells(outputRow, 11)
Rng.Value = LL75
Set Rng = Sheets("Samples").Cells(outputRow, 12)
Rng.Value = UL75
I have additionally tried:
Setting Tools | Options | General | Break on All Errors. No additional information or error messages are shown.
Adding an On Error Goto: (to obtain further information).
What am I overlooking?