Sub COPY_COL_FROM_PATTERN_AS_VALUES_BETWEEN_WORKSHEETS_DYNAMIC_LASTCOL(SourceWS As String, DestWS As String, ColumnPattern As String)
Application.DisplayAlerts = False
On Error Resume Next
Worksheets(SourceWS).Activate
SELECT_COL_FROM_PATTERN (ColumnPattern)
Selection.Copy
Worksheets(DestWS).Activate
Range(GET_LAST_EMPTY_COLUMN_FROM_RANGE("A1")).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
On Error GoTo 0
Application.DisplayAlerts = True
End Sub
Function SELECT_COL_FROM_PATTERN(Pattern As String)
' Example - SELECT_COL_FROM_PATTERN "Timestamp"
Dim PatternAddress As String
PatternAddress = Cells.Find(What:=Pattern, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Address
SELECT_COL_FROM_RANGE PatternAddress
End Function
Function GET_LAST_EMPTY_COLUMN_FROM_RANGE(FromRange As String)
' Example - GET_LAST_EMPTY_COLUMN_FROM_RANGE "A1"
Dim startColNumber1, startRowNumber1 As Long
Dim startColLetter1 As String
startRowNumber1 = Range(FromRange).Row
LastColNumber1 = Cells(startRowNumber1, Columns.Count).End(xlToLeft).Column + 1
lastColLetter1 = ColumnLetter(LastColNumber1)
GET_LAST_EMPTY_COLUMN_FROM_RANGE = lastColLetter1 & startRowNumber1
End Function
Function SELECT_COL_FROM_RANGE(FromRange As String)
' Example - SELECT_COL_FROM_RANGE "A2"
Range(FromRange).Select
Dim startColNumber, startRowNumber As Long
Dim startColLetter As String
startColNumber = Range(FromRange).Column
startRowNumber = Range(FromRange).Row
startColLetter = ColumnLetter(startColNumber)
LastRowNumber = Range(startColLetter & Rows.Count).End(xlUp).Row
LastColNumber = Cells(startRowNumber, Columns.Count).End(xlToLeft).Column
LastColLetter = ColumnLetter(LastColNumber)
Set rng = Range(startColLetter & startRowNumber & ":" & ActiveSheet.Range(startColLetter & "65536").End(xlUp).Address)
'MsgBox rng.Address
rng.Select
End Function