VBA Finding name header and sum values

Status
Not open for further replies.

Palucci

Banned user
Joined
Sep 15, 2021
Messages
138
Office Version
  1. 365
Platform
  1. Windows
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?

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
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Status
Not open for further replies.

Forum statistics

Threads
1,214,394
Messages
6,119,263
Members
448,881
Latest member
Faxgirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top