Thursday, 13 September 2012

Macro To Combine or Merge or Consolidate Desired or Specific Sheets In One Sheet

Macro To Combine or Merge or Consolidate Specific Desired Sheets In One Sheet

Sub ConsolDesireSheets()
Dim x As Integer
Dim y As Integer
Dim a As Worksheet
Dim b As Integer

b = 1 'INCREMENT VARIABLE

For Each a In Worksheets(Array("Sheet1", "Sheet3", "Sheet5"))
'ONLY SHEETS DEFINED ARRAY ARE CONSOLIDATED IN GIVEN ORDER FOLLOWING EACH’
a.Activate
For x = 2 To 100 'ROWS HAVING THE DATA’
b = b + 1 'DATA BEGINS FROM 2 ROW IN CONSOLIDATED SHEET’

For y = 1 To 6 'COLUMNS HAVING THE DATA’
Sheets ("MAIN").Cells (b, y) = a.Cells(x, y)
Next y

If Cells(x, 1) = "" Then Exit For
Next x
'b = b - 2 'JOINS EACH SHEET DATA TOGETHER’
           'ELSE EACH SHEET DATA IS DIVIDED BY A SINGLE EMPTY ROW’
Next a

End Sub

No comments:

Post a Comment

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts