MS_Xsmell
Board Regular
- Joined
- Jan 27, 2007
- Messages
- 76
- Office Version
- 365
- Platform
- Windows
Hello friends, I am using the consolidation function in excel to collect data from a number of worksheets. The code currently consolidates data on all tabs named 0,1,2,3,4,5,...."tab count" ("tabcount" representing the last tab name (currently at 50)).
I would like to update my code to only consolidate specific tabs in the range. In this case, I want to consolidate all tabs related to "Company 1" in the table below.
My current code follows:
Thank you!
I would like to update my code to only consolidate specific tabs in the range. In this case, I want to consolidate all tabs related to "Company 1" in the table below.
My current code follows:
Excel Formula:
Sub ConsolidateTabs()
Sheets("consl").Select
'Clear
Sheets("Consl").Range("a1").Select
Rows("1:165").Select
Selection.ClearContents
Sheets("Consl").Range("d10").Select
'Consolidated Sheets
Dim i As Long, arr() As Variant
ReDim arr(0 To Range("tabcount"))
For i = 0 To UBound(arr)
arr(i) = "'" & i & "'!R10C4:R160C240"
Next
Selection.Consolidate arr, xlSum, True, True, False
End Sub
Thank you!