M
mikespeck
I've got this formula. It currently accepts data comeing from an OPC
server int A3, Whenever that changes the data drops down one cell along
with the date and time which is in B4. My question is I want cells d4
through L4 to drop down whenever A3 does.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range(Target.Address), Me.Range("A3:B3")) _
Is Nothing Then
Me.Cells(Me.Range("A:A").Rows.Count, Target.Column).Clear
Dim rgOldValues As Range
Dim iLastRow As Long
iLastRow = Me.Cells(Columns(Target.Column).Rows.Count, Target.Column)
_
..End(xlUp).Row
Application.EnableEvents = False
Select Case iLastRow
Case 1
Case 2
Case 3
Range("A4").Value = Range("A3").Value
Range("B4").Value = Now
Cells(4, Target.Column).Value = Cells(3, Target.Column).Value
Case Else
vaOldValues = Me.Range("A4:B" & _
IIf(iLastRow = 4, 5, iLastRow))
Range("A5:B5").Resize(UBound(vaOldValues, 1), 2).Value = _
vaOldValues
Range("A4:B4").Value = Range("A3:B3").Value
Range("B4").Value = Now
Set rgOldValues = Me.Range(Cells(Target.Row + 6, Target.Column), _
Cells(iLastRow, Target.Column))
Cells(4, Target.Column).Value = Cells(3, Target.Column).Value
End Select
Application.EnableEvents = True
End If
End Sub
server int A3, Whenever that changes the data drops down one cell along
with the date and time which is in B4. My question is I want cells d4
through L4 to drop down whenever A3 does.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range(Target.Address), Me.Range("A3:B3")) _
Is Nothing Then
Me.Cells(Me.Range("A:A").Rows.Count, Target.Column).Clear
Dim rgOldValues As Range
Dim iLastRow As Long
iLastRow = Me.Cells(Columns(Target.Column).Rows.Count, Target.Column)
_
..End(xlUp).Row
Application.EnableEvents = False
Select Case iLastRow
Case 1
Case 2
Case 3
Range("A4").Value = Range("A3").Value
Range("B4").Value = Now
Cells(4, Target.Column).Value = Cells(3, Target.Column).Value
Case Else
vaOldValues = Me.Range("A4:B" & _
IIf(iLastRow = 4, 5, iLastRow))
Range("A5:B5").Resize(UBound(vaOldValues, 1), 2).Value = _
vaOldValues
Range("A4:B4").Value = Range("A3:B3").Value
Range("B4").Value = Now
Set rgOldValues = Me.Range(Cells(Target.Row + 6, Target.Column), _
Cells(iLastRow, Target.Column))
Cells(4, Target.Column).Value = Cells(3, Target.Column).Value
End Select
Application.EnableEvents = True
End If
End Sub