PDA

View Full Version : VBA code help 2016



eydani
04-05-2018, 06:34 AM
please tell me where is problem. thanks

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
Next
MsgBox "Total" &cat& "is" &counter


End Sub

Bob Phillips
04-05-2018, 07:00 AM
It's probably in the code!

eydani
04-05-2018, 07:13 AM
It's probably in the code!
for example search for "PS10" in column "A" and tell QTY (QTY is in column "B")for example PS10=34

Paul_Hossler
04-05-2018, 11:11 AM
It's probably in the code!

:rofl:



But seriously folks ...

An example or more information would be helpful

Attach a workbook and a DETAILED and SPECIFIC description of the problem