LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default loop does not work correctly

please help. I have put together a macro that will open up a folder
with my spreadsheets. The spreadsheets have a built in macro that will
copy the information i need. The next step is to place them into my
summary sheet which is where I run the original macro. The problem is
there are 4 spreadsheets in the folder, but for some reason it is only
pasting the information from workbooks 1 and 3 somehow ignoring 2 and
4. I think it is something in the loop, but can't figure out what.

any help is much appreciated.

Sub UPDATESUMMARY()

Dim i As Integer
Dim wbResults As Workbook
Dim wbCodeBook As Workbook

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False

On Error Resume Next

Set wbCodeBook = ThisWorkbook

With Application.FileSearch
.NewSearch
'Change path to suit
.LookIn = "C:\Tranportation"
.FileType = msoFileTypeExcelWorkbooks

If .Execute 0 Then 'Workbooks in folder
For i = 1 To .FoundFiles.Count 'Loop through all.
'Open Workbook x and Set a Workbook variable to it
Set wbResults = Workbooks.Open(.FoundFiles(i))
wbResults.RunAutoMacros xlAutoOpen
Windows("PayItem.xls").Activate
Sheets("Summary").Select
Range("A65535").End(xlUp).Offset(1, 0).Select

Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

wbResults.Close SaveChanges:=True


Next i


End If
End With

On Error GoTo 0
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SMALL function seems not to work correctly hdf Excel Worksheet Functions 13 February 16th 08 02:38 PM
Sorting numbers doesn't work correctly GrammyEmmy New Users to Excel 8 June 25th 06 11:45 PM
How do I get Auto-Fit to work correctly? Mickey Dunne Excel Worksheet Functions 0 May 11th 06 01:47 AM
custom filter does not work correctly RJ Excel Discussion (Misc queries) 1 September 9th 05 07:34 PM
RunAutoMacros does not work correctly from vbscript! Juha Vehvilainen Excel Programming 2 January 3rd 04 02:11 AM


All times are GMT +1. The time now is 08:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"