Rafay Ahmed
New Member
Hi Everbody,
Below is a Macro, where I have to add Sorting of Date (from A to Z) before assigning Number to "xyz"
Also, attached is the sheet.
Thanks
Below is a Macro, where I have to add Sorting of Date (from A to Z) before assigning Number to "xyz"
Also, attached is the sheet.
Thanks
Code:
Sub Filter_Assign_Values()
'Setup
Dim FilterStr As String
FilterStr = "xyz"
'Select Worksheet
Sheets("Payments").Select
'Clear Filter
On Error Resume Next
ActiveSheet.ShowAllData
'Apply "Axel" Filter
Dim rng As Range
Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
Set rng = Range("A5:F" & lr)
rng.AutoFilter Field:=2, Criteria1:=FilterStr
'assign values to Filtereed data
Dim cl As Range
Dim x As Integer
Set rng = Range("F6:F" & lr)
x = 1
For Each cl In rng.SpecialCells(xlCellTypeVisible)
cl = "Comp-" & Format(x, "00")
x = x + 1
Next cl
End Sub
Attachments
Last edited by a moderator: