Using Consolidate Methode with a relative Range

Joined
Mar 10, 2011
Messages
1
Reaction score
0
Hello i want to get a relative range and i manage to capture it in an Object , and i want to consolidate it in a different sheet but i get an error always on the methode
here is my code :


Sub Test()
Dim rightRange As Range
Dim leftRange As Range
Dim intialDownrange As Range
Dim initialToprange As Range
Dim totalRange As Range


'Getting the Relative Range
Set rightRange = Worksheets("Details").Range("H1").End(xlDown)
Set leftRange = Worksheets("details").Range("r1").End(xlDown).Offset(-1, 0)
Set intialDownrange = Worksheets("Details").Range(rightRange, leftRange)
Set initialToprange = Worksheets("Details").Range("H2", "R2")
Set totalRange = Worksheets("Details").Range(intialDownrange, initialToprange)

Range("B2").Consolidate Sources:= totalRange
, Function:=xlSum, TopRow:=False, LeftColumn:=True, CreateLinks:=False


i always get a run time error says Consolidate methode of range class failed so pls help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top