LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Help needed to consolidate variable ranges in excel vba

can anyone help? I want to be able to write a piece of vba code that will
automatically scan through a series of worksheets, identify the data range,
and then consolidate each worksheet data range into one sheet.

The problem I have is the 'Consolidate Method' uses an Array for determining
the ranges needed to consolidate.

I've written the following code..

Dim Report As Worksheet
Dim RawData(30) As Range
Dim a As Integer

a = 1

For Each Report In ThisWorkbook.Worksheets

Report.Activate

Range("a3").Select

RName = Report.Name

' following identifies data range

With Application.WorksheetFunction
r = 65537 - .CountBlank(Report.Range("A:A"))
c = 258 - .CountBlank(Report.Range("2:2"))
End With

Set RawData(a) = Report.Range(Cells(2, 1), Cells(r, c))

a = a + 1

Next Report

Worksheets("Sheet1").Range("B3").Consolidate _
Sources:=Array(RawData(1), RawData(2)..etc), _
Function:=xlSum, LeftColumn:=True, TopRow:=True

Many thanks in advance

Rich


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Consolidate tables/ranges with text from multiple worksheets coxa Excel Discussion (Misc queries) 1 November 11th 08 07:03 PM
VBA variable definition help needed. jenn k New Users to Excel 4 September 5th 08 08:55 PM
Help with Variable Ranges! Nelson B. Excel Discussion (Misc queries) 1 August 21st 08 03:30 PM
How do I consolidate data into ranges Jerry Excel Discussion (Misc queries) 8 July 15th 08 09:09 PM
Variable ranges John Contact Excel Worksheet Functions 1 June 17th 05 08:02 AM


All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"