Hi Dom,
I'm still having some issues. Your method works, but the
files open in different workbooks. Maybe I'm on the wrong
page of your mrthod. Here the code:
------------
Sub JDF()
'
' JDF Macro
' Macro recorded 6/14/2006 by hamin
' -- this is for source code counts AFTER output _
-- is complete. There may be multiple lots. This _
' -- will prompt you for the files -- for each worksheet.
'
'
Dim Files As Variant '-- doctor so that the user can open multiple files
Dim SaveAsFile As String 'save file
Dim iLastRow As Long
Dim iCol As Long
Dim i As Long
Dim F As Variant
'---
ChDir "C:\Clients\bc\JDF"
MsgBox Prompt:="Select your jdf****_lot*_sourcecode.txt file(s) from the
ALPHA host."
Files = Application.GetOpenFilename("Text Files,*.txt,All
Files(*.*),*.*", 1, "Open Text Files", , True)
For Each F In Files
If F <> "False" Then
Workbooks.OpenText Filename:=F, _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited,
TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
Semicolon:=False _
, Comma:=False, Space:=False, Other:=True, OtherChar:="=", FieldInfo
_
:=Array(Array(1, 1), Array(2, 1))
Else
Exit Sub
End If
Columns("A:A").EntireColumn.AutoFit
ActiveWindow.Zoom = 85
Rows("1:1").Select
Selection.Insert shift:=xlDown
Range("A1").Select
ActiveCell.FormulaR1C1 = "ClientSourceCode"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Qty"
Range("a1:b1").Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Columns("A:A").EntireColumn.AutoFit
Range("A1").Select
'ActiveWindow.SmallScroll Down:=123
'----------
'total
'----------
With ActiveCell
For i = 1 To 1
iCol = .Column + i - 1
iLastRow = Cells(Rows.Count, iCol).End(xlUp).Row
'Selection.Delete shift:=xlDown
'Selection.Delete shift:=xlDown
If iLastRow > ActiveCell.Row Then
Cells(iLastRow + 1, iCol).FormulaR1C1 = _
"Total"
Cells(iLastRow + 1, iCol).Font.Bold = True
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If
Next i
End With
Cells.Select
Selection.Delete shift:=xlUp
Selection.Delete shift:=xlUp
ActiveWindow.ScrollRow = 1
Range("A1").Select
ActiveWindow.SmallScroll Down:=66
ActiveWindow.ScrollRow = 105
ActiveWindow.ScrollRow = 1
Windows("jdf1012_lot1_sourcecode.txt").Activate
Sheets("jdf1012_lot1_sourcecode").Select
Sheets("jdf1012_lot1_sourcecode").Name = "Lot1"
Sheets("Lot1").Select
Sheets.Add
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Lot2"
ActiveWorkbook.SaveAs Filename:= _
"C:\Clients\Barton Cotton\JDF\JDF1012\JDF1012_ClientSourceCode.xls",
_
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
ChDir "C:\Clients\bc\JDF"
Next F
End Sub
-------------------------------
**This isn't finished. Hopefully this makes sense.
--
Thanks,
Himansu