Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49948

select and sum the values for specific ID

$
0
0
Hi I'm trying to sum a specific values for each user ID in same ID_shop, the user IDs are (81 to 86)

my code is not complete:

Code:

Private Sub deletecancel_Click()
    Dim myRange As Range
  'declare object variable used to iterate through the elements of the cell range
    Dim iCell As Range
    'declare variable to hold value you search for
    Dim myValue As Integer
    Dim myValue1 As Integer
    Dim myValue2 As Integer
    Dim myValue3 As Integer
    Dim myValue4 As Integer
    Dim Lastrow5 As Integer
    LastRow = Cells(Rows.Count, "B").End(xlUp).Row
    Set myRange = Range("B2:B" & LastRow)
    'set value  to search for
    myValue = 81
    myValue1 = 82
    myValue2 = 83
    myValue3 = 84
    myValue4 = 85
    myValue5 = 86
    'loop through each cell (iCell) of the cell range (myRange)
    Application.EnableEvents = False
    For Each iCell In myRange
        'test if value i. If condition is met, clear cell
        If iCell.Value = myValue Or iCell.Value = myValue2 Or iCell.Value = myValue3 Or iCell.Value = myValue4 Or iCell.Value = myValue5 Then
        iCell.Offset(, 3).Value = ..
        End If
    Next iCell
    Application.EnableEvents = True
End Sub

How can I select the values in column C for this users ID and sum them and put the result in the end of ID_shop?
the first sheet is my example of my data and the second is the result that I need
Attached Files

Viewing all articles
Browse latest Browse all 49948

Trending Articles