Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Summing selections from a drop down list

Posted on 2013-05-25
2
Medium Priority
?
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
Faustulus earned 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

609 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