Consulting

Results 1 to 4 of 4

Thread: VBA - Find and find next and sum their value help.

  1. #1

    VBA - Find and find next and sum their value help.

    Hi Team


    Need your help for summing the value between two Header Row (Total) till LastRow,


    Column C is expenditure Column, and Below it Total(header row) and below that expenditure Items.
    Column F is actual expenditure Cost of expenditure item.


    Task is- sum expenditure cost which is in Column F and sum result in front of Total.


    Expected result Which I am expecting pasted in Column I. Please assist. Thanks.






    Regards,
    mg

  2. #2
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    430
    Location
    Hi malleshg24!
    Sub test_1()
    Dim lr&, i&, n#
    With Sheet1
      lr = .Range("C" & Rows.Count).End(xlUp).Row
      For i = lr To 2 Step -1
        If .Cells(i, 3) <> "Total" Then
          .Cells(i, 9) = .Cells(i, 6)
          If .Cells(i, 6) <> "-" Then n = n + .Cells(i, 9)
        Else
          .Cells(i, 9) = n
          n = 0
        End If
      Next i
    End With
    End Sub

  3. #3
    Hi Sir,
    Thanks for your help, need small change in code
    I am getting the result in Column 9, but I want sum result in Column 6 only.
    This Data is profit and loss accounts statement we are summing all exp and putting their sum infront of Total in Column 6.
    here dashes are actual 0 numbers.when I click on that cell it shows 0.




    Regards
    mg

  4. #4
    Hi Team,

    I modified above code as per my requirement and its working now , Thanks for help.

    Regards,
    mg

Posting Permissions

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