Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding numerical values based on multiple values in another column Kazmaniac Excel Worksheet Functions 6 April 4th 07 08:53 PM
duplicate table just values not formulas in the table Rob Charts and Charting in Excel 1 February 18th 07 12:18 PM
adding name values AKPhil Excel Worksheet Functions 7 April 27th 06 01:21 AM
adding name values AKPhil Excel Discussion (Misc queries) 1 April 26th 06 09:41 PM
Populating a table based on values in another table Bri Excel Worksheet Functions 0 January 26th 06 01:23 AM


All times are GMT +1. The time now is 02:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"