Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I am writing code which loops through the files in a folder, points at sheet 1 of each file, copies all the non-empty cells in column B of each sheet 1 (and the rows), pastes this to consolidate worksheet. MY CODE IS FINE - ONLY PROBLEM IS THAT ITS NOT COPYING ALL ROWS Sub SubGetMyData3() Dim objFSO As Object Dim objFolder As Object Dim objFile As Object Dim owb As Workbook Dim i, j As Long Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("C:\My Documents\Career") i = 1 j = 1 For Each objFile In objFolder.Files If objFile.Type = "Microsoft Excel Worksheet" Then Set owb = Workbooks.Open(Filename:=objFolder.Path & "\" & objFile.Name) owb.Worksheets("Sheet1").Cells(i, 2).EntireRow.Copy Destination:=Worksheets("consolidate").Cells(j, 1) i = owb.Worksheets("sheet1").Cells(Rows.Count, "A").Row + 1 j = Worksheets("consolidate").Cells(Rows.Count, "A").End(xlUp).Row + 1 ActiveWorkbook.Close savechanges:=True End If Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copying & Inserting Rows w/o Affecting other Rows Etc. | Excel Worksheet Functions | |||
Copying multiple rows to other worksheets (but amount of rows varies) - How? | Excel Discussion (Misc queries) | |||
Copying Rows | New Users to Excel | |||
Copying over Rows Once | Excel Programming | |||
Copying Rows when hiding other rows | Excel Worksheet Functions |