Basic need is I need my macro turned into formulas or something that can be on the spreadsheet without macros. Work is getting rid of the ability to use macros (disabling all), so I need my codes to work without being codes. I have tried different formulas (find, if, vlookup, etc) and I can't find something that works out completely or easily and user friendly. We are used to having it "easy" with macros, but soon will not have that luxury. I am trying to avoid just copying and pasting and sorting individually (human error is a thing when the spreadsheet is used by a dozen people throughout the day).
What I Want: If first cell in row is value "PD", then cut/paste to sheet named "PD", and then sort by date column/time column.
Any help is appreciated. Thank you in advance!
Example of code below:
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Value2 = "PD" Then
Lastrow = Sheets("PD").Cells(Rows.Count, "A").End(xlUp).Row + 1
Rows(Target.Row).Copy Destination:=Sheets("PD").Rows(Lastrow)
Application.EnableEvents = False
Rows(Target.Row).Delete
Application.EnableEvents = True
End If
End If
Dim ws As Worksheet
For Each ws In Sheets
If ws.Name <> "OS" Then
ws.Sort.SortFields.Clear
ws.Sort.SortFields.Add Key:=Range("I4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ws.Sort.SortFields.Add Key:=Range("J4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ws.Sort
.SetRange Range("A4:Y42")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
Next ws
For Each ws In Sheets
If ws.Name = "OS" Then
ws.Sort.SortFields.Clear
ws.Sort.SortFields.Add Key:=Range("K4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ws.Sort.SortFields.Add Key:=Range("L4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ws.Sort
.SetRange Range("A4:Y42")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
Next ws
End Sub
-dannie
What I Want: If first cell in row is value "PD", then cut/paste to sheet named "PD", and then sort by date column/time column.
Any help is appreciated. Thank you in advance!
Example of code below:
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Value2 = "PD" Then
Lastrow = Sheets("PD").Cells(Rows.Count, "A").End(xlUp).Row + 1
Rows(Target.Row).Copy Destination:=Sheets("PD").Rows(Lastrow)
Application.EnableEvents = False
Rows(Target.Row).Delete
Application.EnableEvents = True
End If
End If
Dim ws As Worksheet
For Each ws In Sheets
If ws.Name <> "OS" Then
ws.Sort.SortFields.Clear
ws.Sort.SortFields.Add Key:=Range("I4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ws.Sort.SortFields.Add Key:=Range("J4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ws.Sort
.SetRange Range("A4:Y42")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
Next ws
For Each ws In Sheets
If ws.Name = "OS" Then
ws.Sort.SortFields.Clear
ws.Sort.SortFields.Add Key:=Range("K4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ws.Sort.SortFields.Add Key:=Range("L4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ws.Sort
.SetRange Range("A4:Y42")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
Next ws
End Sub
-dannie