Hello All,
After going through numerous posts, I have managed to put the following code together that helps me in extracting unique values from Sheet 1 Column C into Sheet 2 column A. What I am trying to add is a condition for unique values only for a date that user will be asked to enter. I am at a loss how to get this done. Have tried looking for the answer in different posts but no luck so far. The dates are in Column A of Sheet 1 and are in the format of dd/mm/yyyy hh:mm. The code is as following thus far.
Any help will be greatly appreciated.
Asad
After going through numerous posts, I have managed to put the following code together that helps me in extracting unique values from Sheet 1 Column C into Sheet 2 column A. What I am trying to add is a condition for unique values only for a date that user will be asked to enter. I am at a loss how to get this done. Have tried looking for the answer in different posts but no luck so far. The dates are in Column A of Sheet 1 and are in the format of dd/mm/yyyy hh:mm. The code is as following thus far.
Code:
Sub Test()
Dim rw As Long, lrw As Long, lrw2 As Long
Dim rSrc As Range
rw = Worksheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row
Set rSrc = Worksheets("Sheet1").Range("C2:C" & rw)
rSrc.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("Z1"), Unique:=True
lrw = Worksheets("Sheet1").Cells(Rows.Count, "Z").End(xlUp).Row
For Each Cell In Worksheets("Sheet1").Range("Z1:Z" & lrw)
If Cell.Value > 600 Then
Cell.ClearContents
End If
Next
Worksheets("Sheet1").Sort.SortFields.Clear
Worksheets("Sheet1").Sort.SortFields.Add2 Key:=Range("Z1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With Worksheets("Sheet1").Sort
.SetRange Range("Z1:Z" & lrw)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Range("Z1").Select
End With
lrw2 = Worksheets("Sheet1").Cells(Rows.Count, "Z").End(xlUp).Row
Sheets("Sheet1").Range("Z2:Z" & lrw2).Copy Sheets("Sheet2").Range("A6")
Sheets("Sheet1").Range("Z1:Z" & lrw2).ClearContents
End Sub
Any help will be greatly appreciated.
Asad