PDA

View Full Version : Solved: Please help with this Code



Uller
03-15-2009, 04:58 PM
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

mdmackillop
03-15-2009, 05:16 PM
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

Uller
03-15-2009, 05:38 PM
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

Bob Phillips
03-15-2009, 05:59 PM
Put this in U3 and copy down

=IF(K2<>K3,SUMIF(K:K,K2,H:H),"")

Uller
03-15-2009, 07:01 PM
That works! Thanks for the response!

mdmackillop
03-16-2009, 11:37 AM
Hi Uller,
If your thread is solved, please mark it so using the Thread Tools dropdown.