Consulting

Results 1 to 6 of 6

Thread: Solved: Please help with this Code

  1. #1

    Question Solved: Please help with this Code

    Hi,

    I'm new to VBA in Excel and am trying to figure out how to get my variable Sumact to show the sum result in the same row of the last cell in the range displaying the word Romeo, but two columns over to the left. If anyone knows how to format this that would be a great help. Thanks!!


    Sub Summation()

    Dim Sumact

    Sumact = Application.SumIf(Range("K:K"), "Romeo", Range("H:H"))

    MsgBox Sumact
    ' or do something else with the Sumact value?


    End Sub
    ULLER

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Uller
    Welcome to VBAX.
    Can you post a sample workbook showing typical data, rthe total you're after and where it should go. Use Manage Attachments in the Go Advanced reply section.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3

    Question

    Hi mdmackillop,

    thanks for the quick response. I have attached the file. To shed some light on what I'm trying to do: I have sorted this sheet of metadata by the Artist header (in yellow). I have referenced the artist Romeo in Column K and am getting the correct sum from the corresponding cells from Column H (which is 63.36), but I am trying to place that total in the empty Column I on the last row that displays Romeo.

    Ideally, I want to do this for each name/artist listed in Column K. The text style/size does not make a difference to me on this, but I go through several of these statements (this one is very small) and do this same summation routine manually over and over...so having this automated would be a tremendous help!

    Let me know what you think.

    -Uller
    ULLER

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Put this in U3 and copy down

    =IF(K2<>K3,SUMIF(K:K,K2,H:H),"")
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    That works! Thanks for the response!
    ULLER

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Uller,
    If your thread is solved, please mark it so using the Thread Tools dropdown.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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