You are here:

Excel/Consolidating the Data


Hi Tom,

I have multiple sheets Containing a word Currencies. I would like to consolidate the data from all the currencies tab in one new tab starting from A7. Also I would like to add their respective Item ID by inserting a new Column in consolidated tab. Item Id will be given in each tab in A4, also tab name contains the item ID.

Existing Currencies Tabs -
1. INT019 Curriencies
2. 12345 Curriencies
3. 123 Curriencies

There may be more or less tabs but the naming convention is going to same. Please help. I will email you the workbook. Let me know if you need any clarification.


Think this is what you want.  I put it in Module8 of your workbook.  It adds the summary sheet if it doesn't exist.  If it does exist, it will append to the existing data in that sheet.

Option Explicit
Sub CopyCurriencies()
Dim sh As Worksheet, sh1 As Worksheet
Dim r As Range, r1 As Range, r1A As Range, i As Long
Dim cell As Range
On Error Resume Next
Set sh = Worksheets("Curriencies")
On Error GoTo 0
If sh Is Nothing Then
 Worksheets.Add After:=Worksheets(Worksheets.Count)
 Set sh = ActiveSheet
 sh.Name = "Curriencies"
End If
For Each sh1 In Worksheets
 If InStr(1, sh1.Name, sh.Name, vbTextCompare) Then
  If sh.Name <> sh1.Name Then
   Set r1A = sh1.Range("A5")
   Set r1 = sh1.Range("A7", sh1.Cells(sh1.Rows.Count, "A").End(xlUp))
   i = 0
   For Each cell In r1
     If Len(Trim(cell)) > 1 Then
       i = i + 1
       Exit For
     End If
   Set r1 = r1.Resize(i, 3)
   Set r = sh.Cells(sh.Rows.Count, "A").End(xlUp).Offset(1, 0)
   r1.Copy r
   Set r = r.Resize(r1.Rows.Count, 1).Offset(0, 3)
   r.Value = r1A.Value
  End If
 End If
End Sub

Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2017 All rights reserved.