Check column if duplicate record exist in VBA-excel -


I am new to VBA macros in Excel, and would just like to ask if anybody to check duplicate records in Excel The function is.

This line of code below removes the duplicate while talking to column A, but I do not really want to delete it without user confirmation, if I want, ask for user confirmation If it wants to be removed or not, like a popup, and then this line will be executed simply, but I do not know that there is a function to check the duplicate I

  ActiveSheet Range ("$ A $ 1: $ D $ 38 "). Remove the Outlook Column: = 1  

Thank you in advance for your help

Please try the following code. I have defined the script to empty the duplicate cell, but you can insert your own code.

FindDuplicates () I dim slow Long J. Long dim lDuplicates as long dim dim rngCheck as RangeCell as RangeCell range RangeDuplicates (RangeCell) Set your range as 'range' (!!!!!) set rngCheck = ActiveSheet.Range ("$ A $ 1: $ D $ 38") 'Number of duplicates found in lDuplicates = 0' checking each cell For every rngCell in rngCheck.Cells Debug.Print rngCell.Address' Only non-blank cells are being checked, so it is not IsEmpty (rngCell.Val Ue) then resizing and duplicate array clearing reDim rngDuplicates (0 to 0) to start the 'counter start range i = 0' set the search method rngDuplicates (i) = rngCheck.Find (what: = rngCell.Value , After: = rngCell, looking: = xlValues, _ lookAt: = xlWhole, SearchOrder: = xlByRows, SearchDirection: = xlNext) 'If we have at least one duplicate, then RGD duplicate (i). Addition & lt; & Gt; RngCell.Address then calculate 'Duplicate Laddlipets = Liduplicate + 1' If yes, continue to fill arrays while rngDuplicates (i) .andres & lt; & Gt; RngCell.Address i = i + 1 ReDim save rngDuplicates (0 to set) rngDuplicates (i) = rngCheck.FindNext (rngDuplicates (i - 1)) loop (except for the last value, which is' with every two copies Ask to 'Start our Cell') for J = 0 Ubound (rngDuplicates, 1) - 1 Select Episode MsgBox ("Original Cell:" & amp; rngCell.Address _ & amp; vbCrLf & "Duplicate Cell: "& amp; rngDuplicates (J) .address _ and & amp; vbCrLf & amp;" Price: "& amp; rngCell.Value _ & amp; vbCrLf & amp;" "_ & amp; vbCrLf & amp; Remove duplicate? "_, VbYesNoCancel or vbExclamation or vbDefaultButton1," got duplicate ") case vbYes' (!!! !!!!) Insert it again Any work you want to do with a duplicate 'Currently this blank cell is set to RNGDPlicates (J). Value = "" case vbCancel 'If cancel is pressed then exit exit all Select sub-end Next if the end of the end of the end, then the next rngCell' Last message call MsgBox ("Total number of duplicates:" & amp; LidPlicat & amp; ".", VbExclamation or vbDefaultButton1, Application.Name) End Sub

PS If you only need to remove dulpicates inside a column, then you need to adjust the rngCheck variable in that specific column.

P.P.S. In my opinion, using conditional formatting is easy.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -