Would it be possible for someone to advise how to combine the following 2 Macros into 1?
Option Explicit
Sub ArchiveReminder()
Dim rngToCopyFrom As Range
With Worksheets("MailMerge-Reminder").Columns("A:Q")
Set rngToCopyFrom = .Resize(LastColumnsRow(.Cells) - 1).Offset(1)
End With
PasteRangeValuesToWorksheet rngToCopyFrom, Worksheets("Archive-Reminder").Columns("A:Q") '<~~ paste values to 1st worksheet
PasteRangeValuesToWorksheet rngToCopyFrom, Worksheets("AcctsDueToBeSusp").Columns("E:U") '<~~ paste values to 2nd worksheet
End Sub
Sub PasteRangeValuesToWorksheet(rngToCopyValuesFrom As Range, rngToPasteTo As Range)
'pastes values from the range passed as the first parameter to the range passed as the second parameter
Dim lastRow As Long
With rngToPasteTo
lastRow = LastColumnsRow(.Cells) '<~~ get last non empty row between all columns of the range to paste to
.Resize(rngToCopyValuesFrom.Rows.Count, rngToCopyValuesFrom.Columns.Count).Offset(IIf(lastRow = 1, 0, lastRow)).Value = rngToCopyValuesFrom.Value '<~~ paste values
End With
End Sub
Function LastColumnsRow(rng As Range) As Long
'gets last non empty row between all columns of the passed range
Dim maxRow As Long, lastRow As Long
Dim cell As Range
With rng
For Each cell In .Resize(1)
lastRow = .Parent.Cells(.Parent.Rows.Count, cell.Column).End(xlUp).Row
If lastRow > maxRow Then maxRow = lastRow
Next cell
End With
LastColumnsRow = maxRow
End Function
The first Macro (above) is to copy information from Sheet 1 to Sheet 2 & 3 and the second Macro (below) is to delete the original information from Sheet 1 after copied over to Sheet 2 & 3.
Sub Clear()
Range("A2:D2").Select
Selection.ClearContents
Rows("3:500").Select
Selection.ClearContents
Range("A2").Select
End Sub
Much appreciated if someone could provide me with a solution.
Regards