I don't know if this below is "proper", but try this concept:
Option Explicit
Dim MultiPage1 As Object '? Is there a declaration for this variable somewhere in your code ?
Dim Region '? Is there a declaration for this variable somewhere in your code ?
Dim DSSN '? Is there a declaration for this variable somewhere in your code ?
Dim SSMU '? Is there a declaration for this variable somewhere in your code ?
Sub HandleError_1()
On Error Resume Next
Dim arr: arr = Evaluate(ActiveWorkbook.Names("L4_Values").RefersTo) ' Is ActiveWorkbook = ThisWorkbook in this case ?
If IsEmpty(arr) Then MsgBox "Something's wrong here - The End": Exit Sub
On Error GoTo 0
Dim is_arr As Boolean: is_arr = True
Dim i&, indx&: If IsArray(arr) Then indx = UBound(arr, 1) Else is_arr = False: indx = 1
Dim x: x = 0
Dim y: y = 0
On Error Resume Next
For i = 1 To indx
x = MultiPage1.Pages("Page_" & Region).Controls("TextBox_" & Region & "_Disc_" & DSSN & "_" & i).Value
y = Evaluate("ROUND(SUMIFS(Metric_" & Region & "_SE_MDS,Attribute_PLLevel4,INDEX(L4_Values," & i & "))/" & SSMU & ",1)")
If Err.Number <> 0 Then x = 0: y = 0 Else GoSub cmp_compare
Next
On Error GoTo 0
If is_arr Then Erase arr Else arr = Empty
Exit Sub
cmp_compare:
On Error GoTo 0: On Error GoTo whats_this
With MultiPage1.Pages("Page_" & Region).Controls("TextBox_" & Region & "_Disc_" & DSSN & "_" & i)
If x = y Then .BackColor = RGB(223, 243, 249) Else .BackColor = RGB(71, 142, 185)
End With
On Error GoTo 0: On Error Resume Next
Return
whats_this:
Dim info$: info = "Error # " & Str(Err.Number) & " was generated by " & Err.Source & ":" & vbCrLf & vbCrLf & Err.Description
MsgBox info, vbOKOnly, "Error", Err.HelpFile, Err.HelpContext
MsgBox "This is THE END", vbOKOnly, " ... :(( ... :(( ..."
End ' ... :) ... but be careful with "this" line ... :) ...
End Sub
Bookmarks