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: 1
Default Problem with file finding macro


I'm trying to extract from a number of files in a folder.

The files are named MS060XXX.0.xls where XXX is a number ranging from
001 to 850.

My error handling works if there is only one file missing in the rang
of files I
want to extract from.

If two ore more files are missing the macro stopps with message "fil
not found"

Could anybody please give me a hint how to solve this problem.

Sub Macro1()
'
' Macro1 Macro
'
Dim i As Integer

For i = Range("I2").Value To Range("I3").Value Step 1

ChDir "E:\beredskap\bensin"

Application.ScreenUpdating = False

On Error GoTo Err

If i < 100 Then

Workbooks.Open Filename:="MS0600" & i & ".0.xls"

Else

Workbooks.Open Filename:="MS060" & i & ".0.xls"

End If

If FileLen(ActiveWorkbook.FullName) 300000 Then

Sheets("Beställning").Activate
Range("A2:C2").Copy

Windows("select_files.xls").Activate
Range("C" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecia
Paste:=xlValues

End If

If i < 100 Then

Windows("MS0600" & i & ".0.xls").Activate
ActiveWorkbook.Close

Else

Windows("MS060" & i & ".0.xls").Activate
ActiveWorkbook.Close

End If
Err:
Next i

Application.ScreenUpdating = True

End Su

--
Al
-----------------------------------------------------------------------
Alf's Profile: http://www.excelforum.com/member.php...nfo&userid=711
View this thread: http://www.excelforum.com/showthread.php?threadid=55076

 
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
Macro problem after copying an Excel File Peter[_14_] Excel Discussion (Misc queries) 5 March 7th 10 11:52 AM
Macro for finding a file on a harddrive Megadrone Excel Worksheet Functions 2 February 22nd 07 06:50 PM
Problem with macro to email file using CDO AmyTaylor[_46_] Excel Programming 1 March 7th 06 01:43 PM
Problem with finding dates in Excel Macro Ped_Esc[_2_] Excel Programming 12 July 22nd 04 03:05 AM
Macro Memory ( Paging File ) Problem Paul Black Excel Programming 2 July 10th 04 09:23 AM


All times are GMT +1. The time now is 08:13 AM.

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

About Us

"It's about Microsoft Excel"