VBA - have a group of cells that update each other across multiple sheets

ksscott

New Member
Joined
Mar 7, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi, I am working in Excel 365, on a spreadsheet with 6 tabs. (All 6 tabs feed off raw data in a 7th tab, but all 6 analyse different parts of the data, hence the separate tabs).

I have dropdown filters in the 1st tab which change the data in all 6 tabs . But I would like to be able to view and change these same filters in all 6 tabs, for a seamless experience.

The filters are in the same cells in all 6 tabs: C3, C4, E3, E4, E5, G3, G4, H3, H4.

After scouring various 2-way solutions on the internet I have managed to get a 2-way relationship going, with the following code:

Pasted in Sheet1: ('Geo - Chart')

Private Sub Worksheet_change(ByVal Target As Range)

VBA Code:
If Not Intersect(Target, Range("C4")) Is Nothing Then
   If Target = Range("C4") Then
      Sheets("Geo - Table").Range("C4").Value = Target.Value
   End If
End If

If Not Intersect(Target, Range("C3")) Is Nothing Then
   If Target = Range("C3") Then
      Sheets("Geo - Table").Range("C3").Value = Target.Value
   End If
End If

If Not Intersect(Target, Range("E3")) Is Nothing Then
   If Target = Range("E3") Then
      Sheets("Geo - Table").Range("E3").Value = Target.Value
   End If
End If

If Not Intersect(Target, Range("E4")) Is Nothing Then
   If Target = Range("E4") Then
      Sheets("Geo - Table").Range("E4").Value = Target.Value
   End If
End If

If Not Intersect(Target, Range("E5")) Is Nothing Then
   If Target = Range("E5") Then
      Sheets("Geo - Table").Range("E5").Value = Target.Value
   End If
End If

If Not Intersect(Target, Range("C3")) Is Nothing Then
   If Target = Range("C3") Then
      Sheets("Geo - Table").Range("C3").Value = Target.Value
   End If
End If

If Not Intersect(Target, Range("G3")) Is Nothing Then
   If Target = Range("G3") Then
      Sheets("Geo - Table").Range("G3").Value = Target.Value
   End If
End If

If Not Intersect(Target, Range("G4")) Is Nothing Then
   If Target = Range("G4") Then
      Sheets("Geo - Table").Range("G4").Value = Target.Value
   End If
End If

If Not Intersect(Target, Range("H3")) Is Nothing Then
   If Target = Range("H3") Then
      Sheets("Geo - Table").Range("H3").Value = Target.Value
   End If
End If

If Not Intersect(Target, Range("H4")) Is Nothing Then
   If Target = Range("H4") Then
      Sheets("Geo - Table").Range("H4").Value = Target.Value
   End If
End If

End Sub

And in Sheet2: ('Geo - Table')
VBA Code:
Private Sub Worksheet_change(ByVal Target As Range)

If Not Intersect(Target, Range("C4")) Is Nothing Then
  If Target = Range("C4") Then
    If Sheets("Geo - Chart").Range("C4").Value <> Target.Value Then
      Sheets("Geo - Chart").Range("C4").Value = Target.Value
    End If
  End If
End If

If Not Intersect(Target, Range("C3")) Is Nothing Then
  If Target = Range("C3") Then
    If Sheets("Geo - Chart").Range("C3").Value <> Target.Value Then
      Sheets("Geo - Chart").Range("C3").Value = Target.Value
    End If
  End If
 End If
 
If Not Intersect(Target, Range("E3")) Is Nothing Then
  If Target = Range("E3") Then
    If Sheets("Geo - Chart").Range("E3").Value <> Target.Value Then
      Sheets("Geo - Chart").Range("E3").Value = Target.Value
    End If
  End If
 End If
 
 If Not Intersect(Target, Range("E4")) Is Nothing Then
  If Target = Range("E4") Then
    If Sheets("Geo - Chart").Range("E4").Value <> Target.Value Then
      Sheets("Geo - Chart").Range("E4").Value = Target.Value
    End If
  End If
 End If
 
 If Not Intersect(Target, Range("E5")) Is Nothing Then
  If Target = Range("E5") Then
    If Sheets("Geo - Chart").Range("E5").Value <> Target.Value Then
      Sheets("Geo - Chart").Range("E5").Value = Target.Value
    End If
  End If
 End If
 
 If Not Intersect(Target, Range("G3")) Is Nothing Then
  If Target = Range("G3") Then
    If Sheets("Geo - Chart").Range("G3").Value <> Target.Value Then
      Sheets("Geo - Chart").Range("G3").Value = Target.Value
    End If
  End If
 End If
 
 If Not Intersect(Target, Range("G4")) Is Nothing Then
  If Target = Range("G4") Then
    If Sheets("Geo - Chart").Range("G4").Value <> Target.Value Then
      Sheets("Geo - Chart").Range("G4").Value = Target.Value
    End If
  End If
 End If
 
 If Not Intersect(Target, Range("H3")) Is Nothing Then
  If Target = Range("H3") Then
    If Sheets("Geo - Chart").Range("H3").Value <> Target.Value Then
      Sheets("Geo - Chart").Range("H3").Value = Target.Value
    End If
  End If
 End If
 
 If Not Intersect(Target, Range("H4")) Is Nothing Then
  If Target = Range("H4") Then
    If Sheets("Geo - Chart").Range("H4").Value <> Target.Value Then
      Sheets("Geo - Chart").Range("H4").Value = Target.Value
    End If
  End If
 End If
 

 
End Sub

(The code is long because I could only get it to work if I specify each filter cell separately; I could not get ranges to work, I got error messages). When I tried to copy this working code to other tabs, I was at a loss because with this method it seems all permutations of 2 tabs might need the same code. I have not been able to get it so that changing the filter on each of the 6 tabs updates the other tabs. Grateful for any help, thank you.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,223,275
Messages
6,171,119
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top