AboutTom Ogilvy Expertise Worked with the program for many years - provided assistance on MS Excel Newsgroups since 1997. Have received the Microsoft MVP award annually since 1999.
I don't answer questions on using Excel in a browser
Since I have no way to test this. Prefer not to answer charting questions. I consider myself to be particularly knowledgeable about using VBA internal to Excel but have no problems with formulas and pivot tables either.
Experience Have Used Excel for 15 - 20 years. Answered in excess of 70,000 Excel related questions in MS Excel newsgroups. Unless obvious, please specify whether you want a worksheet function or macro/VBA solution.
Education/Credentials BS General Engineering (concentration in Industrial Engineering)
MS Operations Research Systems Analysis
Question Hi Tom,
I have about 30 worksheet in the excel same file with the same header and format but i need to collect some data ( wich dosn't =0 in column F for example ) in mastersheet. I was trying with consolidate data but it faild.
is there any function, pivot table or vba code can do this .
thanks in advance
Ahmed
Answer Ahmed,
One way would be to copy all the data to a single sheet, then delete the rows you don't want.
Assumes all the data is contiguous and starts in cell A1 on each sheet.
Sub consolidateData()
Dim sh As Worksheet, sh1 As Worksheet
Dim r As Range, i As Long, lastrow As Long
Worksheets.Add after:=Worksheets(Worksheets.Count)
Set sh = Worksheets(Worksheets.Count)
For Each sh1 In Worksheets
If sh1.Name <> sh.Name Then
If sh1.Index = 1 Then
sh1.Cells.Copy sh.Cells
Else
Set r = sh1.Range("A1").CurrentRegion
Set r = r.Offset(1, 0).Resize(r.Rows.Count)
r.Copy sh.Cells(Rows.Count, 1).End(xlUp)(2)
End If
End If
Next
lastrow = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 2 Step -1
If sh.Cells(i, "F") = 0 Then
sh.Rows(i).EntireRow.Delete
End If
Next
End Sub
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