LastRow_Remove

Removes last row in a table starting certain cell.
Creating and using this function was fun, I needed to remove the last row from a table frequently, maybe after adding some rows using another macro.
StartingFromCell variable will be used to count how many rows in that column, and starting from that row, it will remove last row in table.
Removal of row is happen as EntireRow.Delete, you can use ClearContents instead, line is already there and commented, full row will be affected in both cases.
Needs Countcolumncells, GetColumnName

CodeFunctionName
What is this?

Public

Tested

Original Work
Function LastRow_Remove(Optional StartingFromCell = "A1", Optional Shee = "Active", Optional WB = "This")
    ' Removes last row in table
    ' column of cell StartingFromCell will be used also in counting cells to reach last row
    ' Needs Countcolumncells, GetColumnName
    '
    If WB = "This" Then WB = ThisWorkbook.Name
    If WB = "Active" Then WB = ActiveWorkbook.Name
    If Shee = "Active" Then Shee = ActiveSheet.Name
    NewRow = CountColumnCells(ColumnName(StartingFromCell), , Shee, Range(StartingFromCell).Row) - 1
   
    Workbooks(WB).Worksheets(Shee).Range(StartingFromCell).Offset(NewRow, 0).EntireRow.Delete xlShiftUp
    ' Workbooks(WB).Worksheets(Shee).Range(StartingFromCell).Offset(NewRow, 0).EntireRow.ClearContents
End Function

Optional StartingFromCell = "A1", Optional Shee = "Active", Optional WB = "This"

Views 89

Downloads 41

CodeID
DB ID