I am getting an error when I am trying to capture an old value from a cell: run-time error '13' Type mismatch.
This is the code I am using:
Dim oldValue As Variant
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
oldValue = Target(1, 1).Value
MsgBox oldValue
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
'check if one of the target columns is changed
If Target.Cells.Column = 6 Or Target.Cells.Column = 9 Or Target.Cells.Column = 10 Or Target.Cells.Column = 11 Then
'Set variables
    Dim LogActivity As String
    Dim cRow As Integer
    Dim pRowCount As Integer
    Dim wsPBS As Worksheet
    Dim wsHistoric As Worksheet
    Set wsPBS = Sheets("PBS")
    Set wsHistoric = Sheets("Historic")
    cRow = Target.Cells.Row
    pRowCount = wsHistoric.Range("A" & Rows.Count).End(xlUp).Row + 1
'Check for blanks on PBS sheet and exit if entry is not complete
    Dim BlankCount As Integer
    BlankCount = 0
    If wsPBS.Range("D" & cRow).Value = "" Then BlankCount = BlankCount + 1
    If wsPBS.Range("E" & cRow).Value = "" Then BlankCount = BlankCount + 1
    If wsPBS.Range("F" & cRow).Value = "" Then BlankCount = BlankCount + 1
    If wsPBS.Range("H" & cRow).Value = "" Then BlankCount = BlankCount + 1
    If wsPBS.Range("I" & cRow).Value = "" Then BlankCount = BlankCount + 1
    If wsPBS.Range("J" & cRow).Value = "" Then BlankCount = BlankCount + 1
    If BlankCount >= 1 Then Exit Sub
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
        If Target.Cells.Column = 6 Then LogActivity = "Owner change"
        If Target.Cells.Column = 9 Then LogActivity = "Status change"
        If Target.Cells.Column = 10 Then LogActivity = "Priority change"
        If Target.Cells.Column = 11 Then LogActivity = "Completion rate"
    Range("C" & cRow & ":O" & cRow).Select
        Selection.Copy
    wsHistoric.Select
    wsHistoric.Range("F" & pRowCount).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
    wsHistoric.Range("A" & pRowCount).Value = Date
    wsHistoric.Range("B" & pRowCount).Value = Time
    wsHistoric.Range("C" & pRowCount).Value = Application.UserName
    wsHistoric.Range("D" & pRowCount).Value = LogActivity
    wsHistoric.Range("E" & pRowCount).Value = oldValue
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
End If
End Sub
The value is supposed to be stored in a global dim called 'oldValue' so I can use it later on in my code. The cell I am clicking does contain a string.
Any suggestions?
 
     
    