Sub MoveSelectedToHistory(SelectedCol, DateCol, HistCol As Integer)
' This function adds the texts from the source fields,
' and adds these to the target field.
' The data from the source fields will be separated by
' the text specified below.
'---------------------------------------------------------------
' Specify separator between source fields
Const SEPARATOR = ": "
'---------------------------------------------------------------
SelectedRow = ActiveCell.Row
' If not both source fields contain text the function is not performed
If Cells(SelectedRow, DateCol).Text <> "" And _
Cells(SelectedRow, SelectedCol).Text <> "" Then
newText = Cells(SelectedRow, HistCol).Text
' If target is not empty, add a line feed
If newText <> "" Then
newText = newText + vbCrLf
End If
' Create new text
newText = newText + Cells(SelectedRow, DateCol).Text + _
SEPARATOR + Cells(SelectedRow, SelectedCol).Text
Cells(SelectedRow, HistCol) = newText
' Clear source field
'Cells(SelectedRow, DateCol).ClearContents
Cells(SelectedRow, SelectedCol).ClearContents
End If
End Sub