Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding values from one table to another
This may be very simple..not sure.I need to grab three values from a table
and based on those values, create a fourth value in a second table on another worksheet. Eg - I have a column named Dog, one named Colour and one marked State. So I could have a Poodle, Blue, Pregnant and I could have Spaniel, Red, Spayed. I need to add how many of each I have and display it on a second table...so I might have five Blue Poodles who are Pregnant...or two Red Spaniels that are spayed ....thus the figures I want to return are 5 in the Pregnant Blue Poodle column and 2 in the Spayed Red Spaniel column. Any help would be appreciated - my coding skils are minimal..so be gentle. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding values from one table to another
Assuming your 3 columns are A-C, the following will put the count for
the particular combination in a row in column D. Revise 3rd line from end to put said counts where you want. Sub macro1() Dim c As Range Dim c2 As Range Dim rng As Range Dim iEnd As Integer Dim iCt As Integer iEnd = Sheets("Sheet1").Range("A1").End(xlDown).Row Set rng = Sheets("Sheet1").Range("A2:A" & iEnd) For Each c In rng iCt = 0 For Each c2 In rng If c = c2 And c.Offset(0, 1) = c2.Offset(0, 1) And _ c.Offset(0, 2) = c2.Offset(0, 2) Then iCt = iCt + 1 Next c2 c.Offset(0, 3) = iCt Next c End Sub Hth, Merjet |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding numerical values based on multiple values in another column | Excel Worksheet Functions | |||
duplicate table just values not formulas in the table | Charts and Charting in Excel | |||
adding name values | Excel Worksheet Functions | |||
adding name values | Excel Discussion (Misc queries) | |||
Populating a table based on values in another table | Excel Worksheet Functions |