Select B4 and Run the Code Sub CreateCode() On Error GoTo Err: Dim rng As Range Dim cell As Range Set rng = Application.InputBox("Select the Range of Client Name", , , , , , , 8) i = 1 For Each cell In rng If WorksheetFunction.CountIf(rng.Cells(1, 1).Resize(i, 1), cell.Value) > 1 Then ActiveCell.Value = "Duplicate Client Name" Else ActiveCell.Value = "DM" & Left(cell.Value, 1) & Format(i, "000") End If ActiveCell.Offset(1, 0).Select i = i + 1 Next Set rng = Nothing Set cell = Nothing Set rng = Application.InputBox("Select the Range which need to Copy in Details Sheet", , , , , , , 8) rng.Copy Sheets("Details").Range("A1") Set rng = Nothing Err: If Err.Number <> 0 Then MsgBox "Something Went Wrong", vbInformation End If End Sub From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On Behalf Of kurikkal padinjarappalla Sent: Sunday, July 17, 2011 4:59 PM To: excel-macros@googlegroups.com Subject: $$Excel-Macros$$ To Generate a Code Dear Experts, Hope somebody could help me to solve the problem mentioned in the attached sheet. Thanks in advance. Regards, Kurikkal. -- ---------------------------------------------------------------------------- ------ Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel
Copy of To generate a code.xlsm
Description: application/vnd.ms-excel.sheet.macroenabled.12