Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default EXCEL Opening Multiple Text Files

Help I am trying to write an EXCEL Macro that will open ALL text files
located in a directory (C:\Temp Data\Raw Data).

Run formatting on each file (I.e., locate a certian figure) and then import
the figure to my datasheet. Then close and delete all the Text files in the
directory.

I know how to do everything EXCEPT Open all of the files, and then close ALL
of the Files, after macro has run.

this is my current Macro that works for ONE File.


Sub KillProperly(Killfile As String)
' Macro recorded 12/30/2004 by Ralph M. Hill @ Siemens Managed Services
Helpdesk
'

'
If Len(Dir$(Killfile)) 0 Then
SetAttr Killfile, vbNormal
Kill Killfile
End If
End Sub

Sub HF()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Workbooks.OpenText Filename:= _
"C:\Temp Data\Raw Data\Profiles Harper Woods.txt", _
Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 2), Array(51, 2))

Columns("A:A").EntireColumn.AutoFit
Windows("Macro HF Profile Counts.xls").Activate
Range("G8").FormulaR1C1 = "=VLOOKUP(""Total number of
subscribers"",'Profiles Harper Woods.txt'!C1:C2,2,FALSE)"
Range("G8").Select

Windows("Profiles Harper Woods.txt").Activate
ActiveWindow.Close

KillProperly "C:\Temp Data\Raw Data\Profiles Harper Woods.txt"

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub


Any and all help and or suggestions would be most appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default EXCEL Opening Multiple Text Files

See if this get you started:
http://www.contextures.com/xlfaqMac.html#LoopBooks

HTH. Best wishes Harald

"VexedFist" skrev i melding
...
Help I am trying to write an EXCEL Macro that will open ALL text files
located in a directory (C:\Temp Data\Raw Data).

Run formatting on each file (I.e., locate a certian figure) and then

import
the figure to my datasheet. Then close and delete all the Text files in

the
directory.

I know how to do everything EXCEPT Open all of the files, and then close

ALL
of the Files, after macro has run.

this is my current Macro that works for ONE File.


Sub KillProperly(Killfile As String)
' Macro recorded 12/30/2004 by Ralph M. Hill @ Siemens Managed Services
Helpdesk
'

'
If Len(Dir$(Killfile)) 0 Then
SetAttr Killfile, vbNormal
Kill Killfile
End If
End Sub

Sub HF()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Workbooks.OpenText Filename:= _
"C:\Temp Data\Raw Data\Profiles Harper Woods.txt", _
Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 2), Array(51, 2))

Columns("A:A").EntireColumn.AutoFit
Windows("Macro HF Profile Counts.xls").Activate
Range("G8").FormulaR1C1 = "=VLOOKUP(""Total number of
subscribers"",'Profiles Harper Woods.txt'!C1:C2,2,FALSE)"
Range("G8").Select

Windows("Profiles Harper Woods.txt").Activate
ActiveWindow.Close

KillProperly "C:\Temp Data\Raw Data\Profiles Harper Woods.txt"

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub


Any and all help and or suggestions would be most appreciated.



Reply
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
Opening Multiple Excel Files Steve M Setting up and Configuration of Excel 1 December 5th 08 06:50 AM
Opening multiple Excel files that contain varied selected sheets MLBrownewell Excel Worksheet Functions 0 September 14th 05 05:48 PM
Opening multiple text files Tim U[_2_] Excel Programming 0 June 29th 04 07:57 PM
opening multiple files using VB and running a mcaro in excel den748 Excel Programming 3 May 11th 04 08:35 PM
VBA Excel: Opening Very Large Text Files [email protected] Excel Programming 6 September 21st 03 07:30 PM


All times are GMT +1. The time now is 09:02 AM.

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"