PDA

View Full Version : Solved: VBA that synchronize sheets to another sheet



samabert
06-11-2013, 11:23 PM
Hi all,
I found on the Internet a VBA code that will synchronize a certain range (A1:A10,B1:B10) from sheet 1 within sheet 4. The code (In ThisWorkbook) works fine so far.

Is it possible to change the VBA code that it on the same time also ranges (A1:A10,B1:B10) from sheet 2 and sheet 3 to be synchronized within sheet 4? Respectively for sheet 2 (A1:A10,B1:B10) synchronized within sheet 4 inrange ( A20:A30,B20:B30) and for sheet 3 synchronized within sheet 4 in range (A40:A50,B40:B50).

More info and the basic VBA code are put in the example Test.

Thank you very much in advance.
Marc

nilem
06-12-2013, 05:10 AM
Hi Marc
try it
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Intersect(Target, Sh.Range("A1:A10,K1:K10")) Is Nothing Then Exit Sub
Dim i As Long
Select Case Sh.Name
Case "Sheet1": i = 1
Case "Sheet2": i = 21
Case "Sheet3": i = 40
Case Else: Exit Sub
End Select
With Application
.EnableEvents = False
Sh.Range("A1:A10,K1:K10").Copy Sheets("Sheet4").Cells(i, 1)
.EnableEvents = True
End With
End Sub

samabert
06-12-2013, 08:50 AM
That's excellent, it works perfectly! Thanks very much for taking the time to look at it nilem, you've made my day
Marc