Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have a macro that does the following, it deletes all the data within the
spreadsheet, imports 2 files and then saves the spreasheet. This macro works fine but when filters have been used within the spreadsheet and i come to run the macro the spreadsheet freezes on me everytime. Even if i clear all the filters the error still appears. To work around it i have to remove the filters, exit and save the spreasheet and then re-open it. The Macro then works ok again. Any ideas on why this happens ? The macro i use is below. The code is below, Thanks Sub Qualityimport() ' ' Qualityimport Macro ' Macro recorded 24/07/2006 by COATESD ' ' Application.Goto Reference:="R2C1" With Selection.QueryTable .Connection = "TEXT;K:\Mfgpro\datefile.txt" .TextFilePlatform = xlWindows .TextFileStartRow = 1 .TextFileParseType = xlFixedWidth .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = False .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileFixedColumnWidths = Array(8, 10) .Refresh BackgroundQuery:=False End With Application.Goto Reference:="R4C1" Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Selection.ClearContents Application.Goto Reference:="R4C1" With Selection.QueryTable .Connection = "TEXT;K:\Mfgpro\qextract.prn" .TextFilePlatform = xlWindows .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = False .TextFileSemicolonDelimiter = True .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = False .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) .Refresh BackgroundQuery:=False End With Range("A4,C:C").Select Range("C1").Activate ActiveWindow.SmallScroll ToRight:=2 Range("A4,C:C,G:G,I:I,J:J").Select Range("J1").Activate Columns("G:G").EntireColumn.AutoFit Columns("I:I").ColumnWidth = 10.57 Columns("J:J").ColumnWidth = 7 Columns("C:C").ColumnWidth = 10.14 Columns("C:C").EntireColumn.AutoFit Range("H1").Select ActiveWorkbook.Save Range("C1").Select End Sub Thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Writing a macro that will exit a spreadsheet | New Users to Excel | |||
format macro | Excel Discussion (Misc queries) | |||
Search, Copy, Paste Macro in Excel | Excel Worksheet Functions | |||
Spreadsheet print including macro buttons? | Excel Discussion (Misc queries) | |||
Sample spreadsheet of using macro | Excel Worksheet Functions |