Solved

Summing selections from a drop down list

Posted on 2013-05-25
2
311 Views
Last Modified: 2013-05-26
I have three cells. Each have the same drop down box (list). Each selection within that list is equal to a value (PN1 is 1, PN2 is 2, PN3 is 3..., PN8 is 8).

The fourth cell displays the summation of cells 1-3.

How would a macro be written to accomplish that?

Thanks in advance
0
Comment
Question by:dgd1212
2 Comments
 
LVL 14

Accepted Solution

by:
Faustulus earned 500 total points
ID: 39197140
Would something like this work for you?
Range("D4").Value =  WorksheetFunction.Sum(Range("A1:C1"))

Open in new window

Here D4 is the fourth cell you mentioned. If the cells aren't joined you can enumerate the three cells to be summed. WorksheetFunction.Sum(Range("A1,B2,C3"))

If the job is to determine which selection has been made in each of the drop-downs you would need to tell a little more about the controls' nature. The easiest way would be to read the control's ListIndex property. This property returns 0 for the first choice, 1 for the second and so on. Therefore, the value you wish to assign is ListIndex + 1 and you can sum them up in a loop like,
For i = 1 to 3
    n = n + Control(i).Listindex + 1
Next i
The trouble is that not all drop-downs have the ListIndex property and, even if the property exists, different types of controls must be addressed using slightly (or grossly) different syntax. If you aren't sure of the type of your control I suggest you post your worksheet with the 3 drop-downs in it.
0
 
LVL 81

Expert Comment

by:byundt
ID: 39197948
You might use an array-entered formula for your sum instead of using a macro:
=SUM(IFERROR(MATCH(A1:A3,DropdownChoices,0),))

To array-enter a formula:
1. Paste the formula in the formula bar (or click in the formula bar)
2. Hold the Control and Shift keys down
3. Hit Enter, then release all three keys
Excel should respond by adding curly braces { } surrounding your formula. If not, repeat steps 1 to 3.
SumOfDropdownChoicesQ28139167.xlsx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now