I have a macro that works currently by:
1. Clearing a row from columns A through OJ for whatever cell is currently selected within "Table2".
2. Sorting "Table2" alphabetically based on the values in the Name column - which is column A.
I would like to edit this macro by:
1. Creating a selection prompt for the user to select the row they would like to clear (from columns A through OJ). Instead of having to select the cell before running the macro.
2. Creating a verification prompt for the user to confirm they would like to clear the data for the selected row. This prompt would list the name value in column A for that row and ask something like: "Are you sure you want to clear the data for [name]", and the user would either confirm or reject their selection.
Here is the macro as currently written:
Sub Deleteandsort()
'
' Deleteandsort Macro
'
'
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range("A" & ActiveCell.row & ":OJ" & ActiveCell.row).Select
Selection.ClearContents
ActiveWorkbook.Worksheets("2020 Attendance").ListObjects("Table2").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("2020 Attendance").ListObjects("Table2").Sort. _
SortFields.Add2 Key:=Range("Table2[[#All],[Name]]"), SortOn:=xlSortOnValues _
, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("2020 Attendance").ListObjects("Table2").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
I would really appreciate help in modifying this macro.
Bookmarks