I have some code at the bottom that I want the pochodne sheet to find the name NOMINAL_MAX in the column names and then sum all the values in it. Unfortunately, this code collapses my headrs as if he were put a filter and that's all. What's wrong with this code?
cross post : VBA Finding name header and sum values
VBA Code:
With wbMe.Sheets("pochodne")
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
Set rTable = .Range(.Cells(1, 1), .Cells(LastRow, LastCol))
Set rCol = rTable.Rows(1).Find(What:=NOMINAL_MAX, LookIn:=xlValues, LookAt:=xlWhole)
If Not rCol Is Nothing Then
SumCriteria = Application.WorksheetFunction.SumIf(rTable.Columns(1), Criteria, rTable.Columns(rCol.Column))
Else
SumCriteria = CVErr(xlErrValue)
SumCriteria = wbMe.Sheets("pochodne").Range("X35").Value
End If
End With
cross post : VBA Finding name header and sum values