I am very confused by the length of your macro and that it seems to both
open the file and close it. I had a beast of a time getting the text type
file to open. I could not seem to dimension myfilename as a workbook in
order to do that - only dim'ing it as a variant worked. Can we please,
please assume it is already opened in EXCEL, with all the normal setting of
boundaries that is done with a text-type file, that I then have deleted some
rows on that, copied some of it (see below), never saved it, and now want to
simply close it without saving.
The part of the macro below shows it being opened. At the very bottom, I am
trying to close it. I have tried all the options and all seem to cause a
macro problem.
Dim myFilename As Variant
myFilename = Sheets("Inputs").Range("c28").Value &
Sheets("Inputs").Range("E11").Value & "SUMPRF" & ".*"
'MsgBox myFilename ' **** to see what it is looking for before it bombs
Workbooks.OpenText Filename:=myFilename, Origin:=437, StartRow:=1,
DataType:=xlFixedWidth, FieldInfo:=Array( _
Array(0, 1), Array(7, 3), Array(17, 1), Array(32, 1), Array(40, 1),
Array(48, 1)), _
TrailingMinusNumbers:=True ' this sets the column breaks and seems
to always fit but beware
Application.Goto Reference:="R14C1" ' looks like relative reference for cell
A14
For i = 1 To 1400 '1400 is max possible, if have blocks of about 47
accts each and 65,000 rows
Selection.End(xlDown).Select
If ActiveCell.Row = 65536 Then GoTo l_pool
ActiveCell.Resize(13).EntireRow.Delete
Next i
l_pool: Rem
Selection.End(xlUp).Select ' is this necessary?
Application.Goto Reference:="R1C1" ' guess this is cell A1
x = Cells(Rows.Count, "a").End(xlUp).Row
Range("a1:f" & x).Select
Application.Calculation = xlCalculationManual ' Turn recalc off since this
seems to be just before macro slows down
Selection.Copy
wbTarget.Activate
Sheets("TwtdROR").Select
Application.Goto Reference:="R1C1"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'Workbooks(myFilename).Close SaveChanges:=False ' **** TOM TRYING TO HELP
ME GET THIS TO WORK