Hi Sathish, Thanks a lot for the help.
This shd work with the name of the sheets like Sheet1 Sheet2 etc and that too if the names are missing like for e.g Sheet3 is missing and you have Sheet 4 after Sheet 2 then it will not work correctly... However what I want is any name of the sheet can make the code work. and also it shd copy the first header row from the first sheet. Hope it explains the problem more. regards, Andy On Thu, Apr 2, 2009 at 4:25 PM, Aindril De <aind...@gmail.com> wrote: > Hi All, > > I am trying to write a Macro to do the following: > It will Count the number of sheets in the workbook and then copy the > contents of all the sheets into a sheet called "Results". Following is the > code that I have written. But the problem is the Nested For Loop is not > working. Once it enters in the inner loop, it never comes out of the innet > loop and hence the macro execution ends. > Sub copyRows_1() > Dim SiteCol As Range, Cell As Object, SheetCount As Long, m As Long > Application.Volatile > SheetCount = Sheets.Count > For m = 1 To SheetCount - 1 > Sheets(m).Activate > MsgBox "Copying From Sheet " & ActiveSheet.Name > Set SiteCol = Range("A1:A700") > For Each Cell In SiteCol > If IsEmpty(Cell) Then > Exit Sub > End If > Cell.EntireRow.Copy > Sheets("Results").Activate > ActiveSheet.Range("A65536").End(xlUp).Select > Selection.Offset(1, 0).Select > ActiveSheet.Paste > Next Cell > Next m > End Sub > Need help in arranging the FOR loop properly! > > Thanks in Advance > Andy > > > > --~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---