Hello its me again... sorry to keep on posting about my problem
well here it goes..

If you see in the attached file.
Sum

I have an AM Ervielette, Marriane etc.
now i need to add their Total Calls for Ervie and Total Visits
same goes to the other..

How do i do that?
i search it on web but nothings came out...

Sum1

This post has no text-based content.

This might work for you:

    Public Sub GetTotals(ByVal Name As String)
        Dim Visits, Calls As Integer
        Visits = 0
        Calls = 0
        For Each Itm As ListViewItem In ListView1.Items
            If Itm.Text = Name Then
                Visits += Val(Itm.SubItems(1).Text)
                Calls += Val(Itm.SubItems(2).Text)
            End If
        Next
        MessageBox.Show("Visits - " + Str(Visits) + vbNewLine + "Calls - " + Str(Calls))
    End Sub

You pass the name, you want the totals of, as a string and it produces two totals(Visits and Calls).

Hi @tinstaafi thank you for the reply i going to test the code
but what does this mean?

 If Itm.Text = Name Then

I get it..

dim Name as string = "Cynthia Miguel"
'then execute your code

Great.. but how do i put all the AM Column name to the string?

Sorry though you had that already. Rewrote it so that it'll find all the unique names in AM and total each ones visits and calls and put the results in a listview with 3 columns.

Public Class Form1
    Structure Totals
        Dim Name As String
        Dim Visits As Integer
        Dim Calls As Integer
    End Structure
    Dim Activity As New List(Of Totals)

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        GetTotals()
        For Each Total As Totals In Activity
            ListView2.Items.Add(Total.Name, Total.Name, 0)
            ListView2.Items(Total.Name).SubItems.Add(Str(Total.Calls))
            ListView2.Items(Total.Name).SubItems.Add(Str(Total.Visits))
        Next

    End Sub
    Public Sub GetTotals()
        Dim TempTotal As Totals
        Dim Indx As Integer
        With TempTotal
            .Name = ""
            .Visits = 0
            .Calls = 0
        End With

        For Each Itm As ListViewItem In ListView1.Items
            Indx = CheckName(Itm.Text)
            If Indx = -1 Then
                With TempTotal
                    .Name = Itm.Text
                    .Calls = Val(Itm.SubItems(1).Text)
                    .Visits = Val(Itm.SubItems(2).Text)
                End With
                Activity.Add(TempTotal)
            Else
                TempTotal = Activity.Item(Indx)
                TempTotal.Calls += Val(Itm.SubItems(1).Text)
                TempTotal.Visits += Val(Itm.SubItems(2).Text)
                Activity.Item(Indx) = TempTotal
            End If
        Next

    End Sub
    Public Function CheckName(ByVal Name As String) As Integer
        CheckName = -1
        For Each Total As Totals In Activity
            If Name = Total.Name Then
                CheckName = Activity.IndexOf(Total)
                Return CheckName
            End If
        Next
    End Function
End Class

I made a structure to store the data in an easy format. I then made a list of that data type. The function CheckName takes each name from listview1 and compares it to the names in that list. A match returns its index in the list, otherwise it returns a -1. With this information I either add a new item to the list or add the calls and visits for this item from the listview to the existing item in the list. Once the list is generated the data can be treated however you like. I chose to add the data to listview2.

yes it works thank you so much @tinstaafl :) great help i stuck in here for about 3 days.. i can continue now :D

@tinstaafl what if the AM is in the Second Column? how do i do that?
I can't find where do you search the AM in the code..

i saw it already

'it search in this part where the "AM" is in the first column
    TempTotal.Name = Itm.Text

'change it if the "AM" is in the second column
    TempTotal.Name = Itm.SubItems(1).Text

I think i need some coffee?.. Lol

Hi...@tinstaafl I'm having a problem again
i notice that its only adding all the numbers like
test

as you notice all the Average Sales, Daily Calls and Client Visits have numbers and they are just adding up

for example AILEEN-EB has 3315 Daily Calls
and ALLYSA-F has only 234 Daily Calls
but it appears in the column they just add up 3315 + 234 and display 3546
just what happen also in Average Sales and Client Visits

I'm using the code above

Structure Totals

    Dim Name As String
    'Dim NumSales As Integer
    Dim Sales As Long
    Dim Visits As Integer
    Dim Calls As Integer

End Structure
Dim Activity As New List(Of Totals)
Dim AcctMgrs As New List(Of String)

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    Activity.Clear()
    AcctMgrs.Clear()
    ListView2.Items.Clear()
    GetTotals()
    For Each Total As Totals In Activity
        ListView2.Items.Add(Total.Name, Total.Name, 0)
        'ListView2.Items(Total.Name).SubItems.Add(Format(Total.Sales / Total.NumSales, "fixed"))
        ListView2.Items(Total.Name).SubItems.Add(Format(Total.Sales, "fixed"))
        ListView2.Items(Total.Name).SubItems.Add(Str(Total.Calls))
        ListView2.Items(Total.Name).SubItems.Add(Str(Total.Visits))
    Next

End Sub

Public Sub GetTotals()
    Dim TempTotal As Totals
    Dim Indx As Long
    With TempTotal
        .Name = ""
        .Visits = 0
        .Sales = 0
        .Calls = 0
        '.NumSales = 0
    End With
    'Load each name fro lvAccountManager into the AcctMgrs list
    For Each Itm As ListViewItem In Me.lvAccountManager.Items
        'Check if the name already exists.
        'CheckName returns -1 if false, otherwise we ignore it.
        'We only want 1 instance of each name in Activity,
        'as it will hold the totals
        Indx = CheckActivityForName(Itm.SubItems(1).Text)
        If Indx = -1 Then
            AcctMgrs.Add(Itm.SubItems(1).Text)
        End If
    Next
    For Each Name As String In AcctMgrs
        'Get total visits and calls for each item we put into Activity
        For Each Itm As ListViewItem In ListView1.Items
            If Itm.SubItems(1).Text = Name Then
                TempTotal.Name = Name
                TempTotal.Visits += Val(Itm.SubItems(3).Text)
                TempTotal.Calls += Val(Itm.SubItems(2).Text)
            End If
        Next
        'Get total sales and transactions for each item
        For Each Itm As ListViewItem In lv.Items
            If Itm.SubItems(1).Text = Name Then
                'Average sales will be Sales/NumSales
                TempTotal.Sales += Val(Itm.SubItems(9).Text)
                'TempTotal.NumSales += 1
            End If
        Next
        Activity.Add(TempTotal)
    Next

End Sub
Public Function CheckActivityForName(ByVal Name As String) As Integer

    'false is the default
    CheckActivityForName = -1
    For Each ExistingName As String In AcctMgrs
        'true returns the index of the item
        If Name = ExistingName Then
            CheckActivityForName = AcctMgrs.IndexOf(ExistingName)
            Return CheckActivityForName
        End If
    Next

End Function

Please help me again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.