Saturday, April 20, 2019

To mirror data or active cell equal the another data

To mirror data or active cell equal the another data


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'On Error Resume Next
If Target.Address = Sheets("Payslip").Range("$A$2") Then
Target.Value = ""
Else
Sheets("Payslip").Range("b19") = ActiveCell
End If
End Sub

Another sample if many data need to mirror

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Sheets("Input Billing").Range("$A$2") Then
Target.Value = ""
Else
Sheets("Maintenance").Range("d1") = ActiveCell


End If

If Target.Address = Sheets("Input Billing").Range("$A$2") Then
Target.Value = ""
Else
Sheets("Maintenance").Range("d2") = ActiveCell.Offset(0, 1)


End If

If Target.Address = Sheets("Input Billing").Range("$A$2") Then
Target.Value = ""
Else
Sheets("Maintenance").Range("d3") = ActiveCell.Offset(0, 2)


End If


If Target.Address = Sheets("Input Billing").Range("$A$2") Then
Target.Value = ""
Else
Sheets("Maintenance").Range("d4") = ActiveCell.Offset(0, 3)


End If

If Target.Address = Sheets("Input Billing").Range("$A$2") Then
Target.Value = ""
Else
Sheets("Maintenance").Range("d5") = ActiveCell.Offset(0, 4)

End If



If Target.Address = Sheets("Input Billing").Range("$A$2") Then
Target.Value = ""
Else
Sheets("Maintenance").Range("d6") = ActiveCell.Offset(0, 5)

End If
End Sub




No comments:

Post a Comment