Consulting

Results 1 to 5 of 5

Thread: Multiply two columns and sum a column in Listview

  1. #1

    Multiply two columns and sum a column in Listview

    Dear developpers,

    I am stuck in a form to check calculations before sending them to worksheet .


    I have to multiply two columns 3 and 5 and then sum column 6 total and display total in a listbox.

    herewith my file for better clarifications and I am ready for any questions,

    Thanks in advance,
    Attached Files Attached Files

  2. #2
    VBAX Newbie
    Joined
    Mar 2016
    Posts
    1
    Location
    Hello djemy,

    you have to :

    1. add another textbox named textTotal

    2. add in your USF code these two procedures

    Private Sub textPrix_Change()
    textTotal.value = textPrix.value * textQté.value
    End Sub
    
    Private Sub textQté_Change()
    textTotal.value = textPrix.value * textQté.value
    End Sub
    3. add in your Sub UserForm_Initialize :

    Private Sub UserForm_Initialize()
    Dim i As Long, Ttl As Currency
    On Error Resume Next
    For i = 1 To ListView1.ListItems.Count
        Ttl = Ttl + CDbl(ListView1.ListItems(i).ListSubItems(5).Text)
    Next
    textHT.value = Ttl
    End Sub
    Cordially, Hafid

  3. #3
    Dear Hafid,

    I am so leased to receive a quick rely .I will test your code and let you know if it is suitable.

    Again thanks,

  4. #4
    Hi Hafid,

    The first step is working (column 5 * column 3),but still the sum of column 6 is not working.Could you help me figure it out.

    Thanks in advance,

    Herewith my file amended
    Attached Files Attached Files

  5. #5
    Quote Originally Posted by Hafid View Post
    Hello djemy,

    you have to :

    1. add another textbox named textTotal

    2. add in your USF code these two procedures

    Private Sub textPrix_Change()
    textTotal.value = textPrix.value * textQté.value
    End Sub
    
    Private Sub textQté_Change()
    textTotal.value = textPrix.value * textQté.value
    End Sub
    3. add in your Sub UserForm_Initialize :

    Private Sub UserForm_Initialize()
    Dim i As Long, Ttl As Currency
    On Error Resume Next
    For i = 1 To ListView1.ListItems.Count
        Ttl = Ttl + CDbl(ListView1.ListItems(i).ListSubItems(5).Text)
    Next
    textHT.value = Ttl
    End Sub
    Cordially, Hafid
    Again thank you I was able to figure it out depending on your code and it 's working like a charm now.

    Many thanks Mr Hafid,
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •