I have an excel sheet which on one master tab I have the list of names of companies which is then referenced by 34 sheets covering various details about the company. In the 34 specific sheets data is entered and then pulled back into the master tab.
A flow chart for reference:
Master(Names) -> 34 Subsheets Subsheets(Information) -> Mastersheet
With how I have laid this out I am having trouble finding a way to add now companies to the master list, as the cells being referenced on the subsheets do not automatically get moved down. This results in things being misreferenced.
The solution I am interested in but don't know how to do is to create a macro in VBA that is always running and will add/remove a new row to all the subsheets in the exact same place it is added to the main sheet.
Ex,, If on the main sheet a new row is added between rows 50 and 51, then on all the subsheets a new row will be added as well.
I am completely lost as to how to do this, so any and all help would be appreciated. Thank you, and have a nice day!
I'm not even sure where to begin with this I apologize.
Edit: I have since come up with a solution to this problem. which is posted below, in case someone else has this same question later on.
Option Explicit
Public Sub Worksheet_Change(ByVal Target As Range)
Dim ws
Dim trgtRow
Dim NewRowCount As Long
Dim OldRowCount As Long
trgtRow = Target.Row
OldRowCount = Sheet3.UsedRange.Rows.Count
NewRowCount = Sheet2.UsedRange.Rows.Count
If Not Application.Intersect(Range("A2:A100"), Target) Is Nothing Then
For Each ws In ThisWorkbook.Worksheets
ElseIf ws.Name <> Sheet2.Name Then
If OldRowCount < NewRowCount Then
ws.Rows(trgtRow).Insert Shift:=xlDown
ElseIf OldRowCount > NewRowCount Then
ws.Rows(trgtRow).Delete Shift:=xlUp
End If
End If
Next ws
End If
End Sub