hi i need to make changes to the data transfer. I need to add more columns and add more data. can you tell me which parts of the code i need to change please? It's due tomorrow and i need to get this fixed today, please help. I tried deleting a column and that messed up the transfer....
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
Dim matchfound As Variant
If Target.Count > 1 Then GoTo exitHandler
If Target.Value = vbNullString Then GoTo exitHandler
Start:
If Application.Intersect(Target, Range("C2:C1000")) Is Nothing Then GoTo FirstStep:
With Worksheets("Timeline Status")
lastrow = .Range("A" & Rows.Count).End(xlUp).Row
matchfound = Application.Match(Target.Offset(, 1).Value, .Range("A2:A" & lastrow), 0)
If IsError(matchfound) Then
.Cells(lastrow + 1, "A").Value = Target.Value
.Cells(lastrow + 1, "B").Value = Target.Offset(, -1).Value
End If
End With
GoTo exitHandler:
FirstStep:
If Application.Intersect(Target, Range("F2:F1000")) Is Nothing Then GoTo SecondStep:
With Worksheets("Timeline Status")
lastrow = .Range("A" & Rows.Count).End(xlUp).Row
matchfound = Application.Match(Target.Offset(, -3).Value, .Range("A2:A" & lastrow), 0)
matchfound1 = Application.Match(Target.Offset(, -1).Value, Worksheets("Settings").Range("A3:A13"), 0) + 2
If IsNumeric(matchfound) Then
.Cells(matchfound + 1, "A").Value = Target.Offset(, -3).Value
.Cells(matchfound + 1, "B").Value = Target.Offset(, -4).Value
.Cells(matchfound + 1, matchfound1).Value = Target.Value
Else
.Cells(lastrow + 1, "A").Value = Target.Offset(, -3).Value
.Cells(lastrow + 1, "B").Value = Target.Offset(, -4).Value
.Cells(lastrow + 1, matchfound1).Value = Target.Value
End If
End With
GoTo exitHandler
SecondStep:
If Application.Intersect(Target, Range("J2:J1000")) Is Nothing Then GoTo ThirdStep:
With Worksheets("Timeline Status")
lastrow = .Range("A" & Rows.Count).End(xlUp).Row
matchfound = Application.Match(Target.Offset(, -7).Value, .Range("A2:A" & lastrow), 0)
If IsNumeric(matchfound) Then
.Cells(matchfound + 1, 14).Value = Target.Value
End If
End With
ThirdStep:
If Application.Intersect(Target, Range("K2:K1000")) Is Nothing Then GoTo LastStep:
With Worksheets("Timeline Status")
lastrow = .Range("A" & Rows.Count).End(xlUp).Row
matchfound = Application.Match(Target.Offset(, -8).Value, .Range("A2:A" & lastrow), 0)
If IsNumeric(matchfound) Then
.Cells(matchfound + 1, 15).Value = Target.Value
End If
End With
LastStep:
On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If Target.Column = 4 Then
If oldVal = "" Then
Else
If newVal = "" Then
Else
Target.Value = oldVal & ", " & newVal
End If
End If
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub