Option Explicit
Sub LastRowInNColumns()
Dim LastRow As Long 'LastRow in Column being searched
Dim AddRemRow As Long 'next row position to add range from Column being searched
Dim CurrCol As Long 'Column being searched
Dim TabColumnsToBeSearched As String 'Name of Tab containing Columns being searched
Dim TabAddRemove As String 'Name of Tab containing Unique Values
TabAddRemove = "AddRemove" 'Specify name of Tab containing Unique Values
TabColumnsToBeSearched = "SchedID" 'Specify Name of Tab containing Columns being searched
'================================================
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
'================================================
'================================================
'Delete Unique Tab, if it exists; create a blank one
On Error Resume Next
Sheets(TabAddRemove).Delete
On Error GoTo 0
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = TabAddRemove
'================================================
'Activate tab with Columns to be searched
Sheets(TabColumnsToBeSearched).Activate
AddRemRow = 2
CurrCol = 1
Sheets("AddRemove").Range("A1") = "Unique SchedIDs" 'Title the Column
With ActiveSheet
'================================================
' Cycle through each Column checking for a value in A+Column#
' Calculate the # of rows, copy the range, paste into the next available slot in the Unique tab
Do While Range(Cells(1, CurrCol), Cells(1, CurrCol)) > ""
LastRow = .Cells(.Rows.Count, CurrCol).End(xlUp).Row
Debug.Print "Column: " & CurrCol & " - Rows: " & LastRow - 1
Range(Cells(2, CurrCol), Cells(LastRow, CurrCol)).Copy Sheets("AddRemove").Range("A" & AddRemRow)
AddRemRow = AddRemRow + LastRow - 1
CurrCol = CurrCol + 1
Loop
End With
'================================================
' Active the Unique Tab; Remove the Dupes; Display the number of rows - 1
Sheets("AddRemove").Activate
Range("A:A").RemoveDuplicates Columns:=Array(1), Header:=xlYes
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Debug.Print "Unique Values: " & LastRow - 1
'================================================
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
'================================================
End Sub