Recorded a macro and then cleaned it up. Use the second macro. Sub MakeUniqueNumbers(). Save file as .xlsM
Sub Macro2() 'recorded ' ' Macro2 Macro ' ' Range("D1").Select Range("C1:D26").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _ "H1"), Unique:=True Columns("I:I").EntireColumn.AutoFit Range("H2").Select ActiveCell.FormulaR1C1 = "1" Range("H3").Select ActiveCell.FormulaR1C1 = "2" Range("H2:H3").Select Selection.AutoFill Destination:=Range("H2:H15"), Type:=xlFillDefault Range("H2:H15").Select Range("G1").Select End Sub Sub MakeUniqueNumbers() Range("c1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _ CopyToRange:=Range("H1"), Unique:=True Columns("I").AutoFit Range("H2") = 1 Range("H3") = 2 Range("H2:H3").AutoFill Destination:= _ Range("H2:H" & Cells(Rows.Count, "H").End(xlUp).Row) End Sub Don Guillett SalesAid Software dguille...@gmail.com From: Aamir Shahzad Sent: Tuesday, December 27, 2011 4:37 AM To: excel-macros@googlegroups.com Subject: $$Excel-Macros$$ Create Uni Code Dear Group, If I have some names & I want to create the unique codes how do I? I am using code function but it creates some duplicates. Please see the attached file & suggest. Regards, -- Regards, Aamir Shahzad -- FORUM RULES (934+ 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 -- FORUM RULES (934+ 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