![]() |
Macro freezes after using Filters.
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. Thanks |
Macro freezes after using Filters.
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 "Don Guillett" wrote: as ALWAYS, post your code for comments -- Don Guillett SalesAid Software "davemel" wrote in message ... 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. Thanks |
All times are GMT +1. The time now is 08:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com