Avatar of Roberto Madro R.
Roberto Madro R.
Flag for United States of America asked on

Automatically populate one Excel sheet when data is entered in another sheet within the same workbook

In Excel, I want to automatically copy data as it's entered in one sheet onto another where the columns in both sheets are identical.
Microsoft OfficeMicrosoft ExcelVBA

Avatar of undefined
Last Comment
Subodh Tiwari (Neeraj)

8/22/2022 - Mon
Subodh Tiwari (Neeraj)

Why not upload a sample file with the desired output mocked up manually to show what exactly you are trying to achieve?
Roberto Madro R.

ASKER
There's really nothing special here:

Sheet1: Name, PhoneNumber,Age
Sheet2:Name, PhoneNumber,Age
            James, 123 456 7890, 30
             Mark, 234 567 8910, 25

If someone is entering data on Sheet2 I want to capture that automatically onto sheet1.
ASKER CERTIFIED SOLUTION
Subodh Tiwari (Neeraj)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Rob Henson

A manual option is to group the sheets then any change on one sheet will be made on both.

Select Sheet1 and then press the Ctrl key and select Sheet2; both tabs will be white rather than the usual grey or their colour if coloured.

Can I ask why you need two sheets of the same data??
Your help has saved me hundreds of hours of internet surfing.
fblack61
Martin Liss

I would modify Neeraj's code so that it looks like this, This version will allow you to do things like capture the pasting of a range of data, change headings and capture changes to all cells and not just those in the first three columns.
Private Sub Worksheet_Change(ByVal Target As Range)

Dim dws As Worksheet
Set dws = ThisWorkbook.Worksheets("Sheet1") 'Name of the destination Sheet

dws.Range(Target.Address).Value = Target.Value

End Sub

Open in new window

Roberto Madro R.

ASKER
Thank you experts, Rob & Martin, I used the solution Subodh proposed and it worked wonderfully, thanks Subodh. 
Subodh Tiwari (Neeraj)

You're welcome Roberto! Glad it worked as desired.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Roberto Madro R.

ASKER
Subodh, a follow up question, one sheet is overwriting another sheet, can we select the next empty row instead ?
Subodh Tiwari (Neeraj)

Instead of copying individual value, how about copying name, phone and age at once when the age is entered in column C? That way it would be easy to track the empty row.

So as per the below code, once you input the age in column C, the whole record will be transferred to the Sheet1 in the next empty row. Please replace the existing code with the following code to test it.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub

Dim dws As Worksheet
Dim dlr As Long
Dim r   As Long

Set dws = ThisWorkbook.Worksheets("Sheet1") 'Name of the destination Sheet

If Target.Column = 3 And Target.Row > 1 Then
    r = Target.Row
    dlr = dws.Cells(Rows.Count, 3).End(xlUp).Row + 1
    Range("A" & r & ":C" & r).Copy dws.Range("A" & dlr)
End If

End Sub

Open in new window


Roberto Madro R.

ASKER
The multiple sheets could be filled out at different times by different people, I just need to start at the next non-empty row when someone enters data on any of the sheets, hopefully my explanation is making sense. thx.

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Roberto Madro R.

ASKER
Worksheets are overwriting each other, I need to select the next non-empty row, thx.

SOLUTION
Subodh Tiwari (Neeraj)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Roberto Madro R.

ASKER
Yes, the example worked as stated, thanks again Subodh.
Subodh Tiwari (Neeraj)

Welcome again Roberto!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.