lRow = Cells(Rows.Count, 1).End(xlUp).Row
должен иметь четко определенный родительский лист.Помните, что вы перебираете серию рабочих листов.То же самое с If Not IsNumeric(Cells(i, 1).Value) Then
.
Sub Refresh()
'
' Warning Code to check if all values are numeric
'-----------------------------------------------------------------------
Dim sh As Worksheet, i As Long, bIsNumeric As Boolean, lRow As Long, errng as range
bIsNumeric = True
For Each sh In ActiveWorkbook.Worksheets
Select Case sh.Name
Case "AltA", "AltB", "AltC1", "AltC2"
lRow = sh.Cells(sh.Rows.Count, 1).End(xlUp).Row
For i = 3 To lRow
If Not IsNumeric(sh.Cells(i, 1).Value) Then
bIsNumeric = False
set errng = sh.Cells(i, 1)
Exit For
End If
Next i
End Select
If Not bIsNumeric Then Exit For
Next sh
If Not bIsNumeric Then
'There are non-numeric values in your range
MsgBox "There are non-numeric values in your range. Go check yourself and try again." _
& chr(10) & errng.address(0, 0, external:=true)
Else
'---------------------------------------------------
' Code to summarize data
With Sheets("AlternativeSummary")
.Activate
.Range("B5").Select
.PivotTables("PivotTable5").PivotCache.Refresh
MsgBox "Complete"
'All values in your range are numeric
end with
End If
End Sub