Macro is removing and Adding Rows

MDuff

Well-known Member
Joined
Dec 29, 2002
Messages
529
Office Version
  1. 365
Platform
  1. Windows
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
 
¡Que dicha! Porque realmente no creí que estuve ayudandole mucho. I lived in Tilarán, Guanacaste for two and a half years - so always glad to help someone in Ticolandia.

Saludos,
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,221,683
Messages
6,161,264
Members
451,692
Latest member
jmaskin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top