Hi please see this codes and tell where is problem

Sub test()

Dim mysheet As Worksheet

Dim lr As Integer

Dim selrow As Integer

Dim cat As Integer

Dim x As Integer

Dim counter As Variant

Set mysheet = ThisWorkbook.Sheets(“sheet1”)

lr = mysheet.Cells(Rows.Count, 1).End(xlUp).Row

selrow = Selection.Row

cat = mysheet.Cells(selrow, 1)

For x = 2 To lr

If mysheet.Cells(selrow, 1) = cat Then

counter = counter + mysheet.Cells(x, 2)

End If


MsgBox “Total” &cat& “is” &counter


End Sub

By: eydani

Leave a Reply

Your email address will not be published. Required fields are marked *