techbutterfly
New Member
- Joined
- Mar 28, 2019
- Messages
- 2
This is my first time posting here, though I've gotten plenty of answers from these forums in the past.
I am using the data consolidation feature in Excel 2013. Because the two sheets I'm consolidating might have different sized ranges each time, I want to capture the used range for each sheet and use them in the consolidate command. I'm getting a type mismatch, but I'm not sure how to resolve it. Here is my code.
Any help is appreciated!
I am using the data consolidation feature in Excel 2013. Because the two sheets I'm consolidating might have different sized ranges each time, I want to capture the used range for each sheet and use them in the consolidate command. I'm getting a type mismatch, but I'm not sure how to resolve it. Here is my code.
Code:
Sub tec_agr_consolidate()
'
' tec_agr_consolidate Macro
'
Dim TEC As Range
Dim IVUE As Range
Worksheets(1).Activate
Set TEC = Worksheets(1).UsedRange
Worksheets(2).Activate
Set IVUE = Worksheets(2).UsedRange
Sheets.Add After:=ActiveSheet
Range("A1").Select
Selection.Consolidate Sources:=Array( _
TEC, IVUE), _
Function:=xlSum, TopRow:=True, LeftColumn:=True, CreateLinks:=False
End Sub
Any help is appreciated!