I'm a new user in VBA and I wrote the following basic code in order to eliminate duplicate data in one sheet and extract unique data into another sheet.
For example:
- in Sheet1 there are total number of 184 cells which contains the same date (12/07/2007) in Column A.
- I desire to take one of that date data and write it to a cell in Sheet2.
- Therefore, there will be 12/07/2007 written in A1 in Sheet2.
I would appreciate any kind of help.
Code:
Sub Take_Unique() Workbooks("historicaldata.xls").Activate Dim i As String Dim xrow As Long xrow = 2 Do Until Sheet1.Cells(xrow, 1) = "" If Sheet1.Cells(xrow, 1).Value = Sheet1.Cells(xrow + 1, 1) Then Sheet12.Cells(xrow, 1).Value = Sheet1.Cells(xrow, 1) End If xrow = xrow + 1 Loop End Sub
Remove Duplicatesfeature or theAdvanced Filter?