Autopopulating multiple sheets from one main sheet

Solved/Closed
Mikey - Updated on Jan 29, 2019 at 03:54 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Oct 5, 2017 at 11:35 AM
Hello,

I'm making an accounting workbook for an organization I am the treasurer for, and I've run into a problem.

On the first sheet "Account", I input all of the transactions that the club has, on a table that goes from C6-H6, and on down for every entry.

One of the columns in the table is labeled "Sector" and refers to which part of the club the expense or revenue came from. There are 7 sectors of the club and they each have a sheet in this workbook.

What I would like to do, is have each individual sector's sheet automatically populate with data when it's inputted onto the main "Account" sheet, and have it based on the Sector column in the table.

So basically, if the sector says "General", I would like for the entire row to be transferred to the sheet "General". And so on for each individual sector.

That way I don't have to copy and paste the hundreds of transactions to individual pages manually.

Any tips or suggestions?

I greatly appreciate any and all help!
Thanks

Michael
System Configuration: Windows 7 / Chrome 24.0.1312.57

14 responses

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Updated on Jan 29, 2019 at 03:56 AM
Hi Michael,

For the code below I created 2 sector's "General" and "1ste Group". Adjust and add to the code to suit your needs:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("H:H")) Is Nothing Then Exit Sub

If Target.Value = "General" Then
Range(Range("C" & Target.Row), Range("H" & Target.Row)).Copy _
Sheets("General").Range("C" & Rows.Count).End(xlUp).Offset(1, 0)

ElseIf Target.Value = "1ste Group" Then
Range(Range("C" & Target.Row), Range("H" & Target.Row)).Copy _
Sheets("1ste Group").Range("C" & Rows.Count).End(xlUp).Offset(1, 0)

End If

End Sub


To implement the code:
  • Right-click on the "Account" tab and select View code.
  • Paste the code in the big white field.


Tip: Have you considered drop-down lists for column H?

Let me know if you get stuck somewhere.

Best regards,
Trowa
9
Hi TrowaD,

Thanks for your code.

I used the code segment successfully,. But, on reopening the file after saving with macro enabled, the code does not seem to run!

What should I do?

Davis
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Apr 26, 2016 at 11:38 AM
Hi Davis,

That is strange, saving your file shouldn't alter the way the code works in any way.

I wouldn't mind taking a look at your file to see what is going on.

Use a free file sharing site like www.speedyshare.com or ge.tt to upload your file and then post back the download link. Always be careful with sensitive information.

I'll get back to you next week, though.

Best regards,
Trowa
0
Hi Trowa

Problem solved.
I had to "Enable Content" Then it is working beautifully.

Sorry for the trouble.

Thanks
Davis
0