I recorded this macro To import a text file. It is working very well but it adds a row on the bottom of the Sheet. Let me explain why, I have all rows from 30 on Hidden to make the sheet look a little nicer for the people who use it. Every time I run it 30 Will disappear and it its place I get 65535 and then if I run it once more 29 will disappear and 65536 this will continue on and on as I run it.
I am not very good with VB coding and this was made with the macro recorder Any help would be very appreciated.
here is the code
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/26/2003 by Mike Duffy
'
Application.ScreenUpdating = False
With ActiveSheet.QueryTables.Add(Connection:="TEXT;E:\stats.txt", _
Destination:=Range("A4"))
.Name = "stats"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(17, 8, 8, 8, 8, 8, 9, 5)
.Refresh BackgroundQuery:=False
End With
Rows("4:4").Select
Selection.Delete Shift:=xlUp
Columns("H:I").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Insert Shift:=xlToRight
Range("F4").Select
ActiveCell.FormulaR1C1 = "Avg"
Range("F5").Select
ActiveCell.FormulaR1C1 = "Handle"
Range("F6").Select
ActiveCell.FormulaR1C1 = "Time "
Range("F7").Select
Columns("F:F").EntireColumn.AutoFit
ActiveCell.FormulaR1C1 = "=SUM(RC[-3]:RC[-1])"
Range("F7").Select
Selection.AutoFill Destination:=Range("F7:F30"), Type:=xlFillDefault
Range("F7:F30").Select
ActiveWindow.SmallScroll Down:=-15
Range("F8").Select
Selection.ClearContents
Application.ScreenUpdating = True
End Sub
thanks
Mike
PS any other advice about cleaning this us would be appreciated also
I am not very good with VB coding and this was made with the macro recorder Any help would be very appreciated.
here is the code
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/26/2003 by Mike Duffy
'
Application.ScreenUpdating = False
With ActiveSheet.QueryTables.Add(Connection:="TEXT;E:\stats.txt", _
Destination:=Range("A4"))
.Name = "stats"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(17, 8, 8, 8, 8, 8, 9, 5)
.Refresh BackgroundQuery:=False
End With
Rows("4:4").Select
Selection.Delete Shift:=xlUp
Columns("H:I").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Insert Shift:=xlToRight
Range("F4").Select
ActiveCell.FormulaR1C1 = "Avg"
Range("F5").Select
ActiveCell.FormulaR1C1 = "Handle"
Range("F6").Select
ActiveCell.FormulaR1C1 = "Time "
Range("F7").Select
Columns("F:F").EntireColumn.AutoFit
ActiveCell.FormulaR1C1 = "=SUM(RC[-3]:RC[-1])"
Range("F7").Select
Selection.AutoFill Destination:=Range("F7:F30"), Type:=xlFillDefault
Range("F7:F30").Select
ActiveWindow.SmallScroll Down:=-15
Range("F8").Select
Selection.ClearContents
Application.ScreenUpdating = True
End Sub
thanks
Mike
PS any other advice about cleaning this us would be appreciated also