vbadatabasedata-entry

VBA: use one cell (as data entry field) to copy data to another tab


I'm currently working in an Excel file and would like to have one cell (say B3) of which the content is automatically pasted in another tab. After replacing the content from B3 by other info, I would still like to have the old info in the other tab, but now supplemented with the new content underneath it. So that the B3 would be sort of a data entry field, and the other tab serves as a 'database'. I think this would require the use of VBA, but I'm very unfamiliar with this, so any help would be great!


Solution

  • you can use worksheet event like this :

    Private Sub Worksheet_Change(ByVal Target As Range)
        ' Change value on cell A1
        If Target.Address = "$A$1" Then
            ' Insert value on column 2
            Me.Cells(1, 2).Insert xlShiftDown
            Me.Cells(1, 2).Value = Target.Value
        End If
    End Sub