I have data like so: Country Year AgeGroup Time Count A 05 1 0-6mo 10 A 05 1 6-12mo 5 ------------------------------------- B 05 1 0-6mo 12 B 05 1 12-18mo 4 B 05 1 18-24mo 75
(I added the "-----" dividing line just to help visualize things ... it's not actually in the spreadsheet.) Every unique group - defined by unique concatenation of Country+Year+AgeGroup should have four rows, one for each of these Time intervals: 0-6mo, 6-12mo, 12-18mo, and 18-24mo. The group defined by CountryA+05+1 is missing rows for 12-18 and 18-24. The group defined by CountryB+05+1 is missing rows for 6-12. How can I automatically detect when a unique group has < 4 rows, and then insert the missing number of rows (doesn't matter where I insert them), imputing the value for County, Year, AgeGroup, and Time (i.e., the Time interval(s) that are missing). Count should get a value of 0. So the code would build and add these three rows: Country Year AgeGroup Time Count A 05 1 12-18mo 0 A 05 1 18-24mo 0 B 05 1 6-12mo 0 Any suggestions? -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com