Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unwanted Querytable Autofilter on ODBC Import

Hi,

I am using the following vba code to import data from an external Excel
workbook, into a another reporting worksheet:

Sheets("CV TEL Data").Select

Rows("1:1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents

Cells.Select
Selection.ClearContents


With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DBQ=W:\INI_Tel_Data.xls;DefaultDir=W:\;Drive r={Driver do
Microsoft Excel(*.xls)};DriverId=790;FIL=excel 8.0;MaxBufferSize=2048;" _
), Array( _

"MaxScanRows=20;PageTimeout=5;ReadOnly=1;SafeTrans actions=0;Threads=3;UID=admin;UserCommitSync=Yes;" _
)), Destination:=Range("$A$1")).QueryTable
.CommandText = Array( _
"SELECT `Sheet1$`.*" & Chr(10) & "FROM `W:\INI_Tel_Data`.`Sheet1$`
`Sheet1$`" _
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_TCM_Tel_Data"
.Refresh BackgroundQuery:=False
End With


When this runs, it gets the data OK, but an unwanted autofilter is created,
which changes the data in 2 number columns in the first row:

01/04/2009 00:29:26 02890839200 288513 00:00:04 F5 F6
01/04/2009 05:56:29 02088813556 288596 00:00:14 14 0
01/04/2009 07:59:58 07814934347 288513 00:00:13 13 0

When this removed using

Cells(1, 6).AutoFilter

The Data in two of the cells is replaced by "F5" "F6"

Is there a way to stop this happening?

Thanks

Andrew



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Unwanted Querytable Autofilter on ODBC Import

I could not test this. Please try and feedback......

Replace Cells(1, 6).AutoFilter with

Activesheet.AutoFilterMode = False

If this post helps click Yes
---------------
Jacob Skaria


"CallScripter Dev" wrote:

Hi,

I am using the following vba code to import data from an external Excel
workbook, into a another reporting worksheet:

Sheets("CV TEL Data").Select

Rows("1:1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents

Cells.Select
Selection.ClearContents


With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DBQ=W:\INI_Tel_Data.xls;DefaultDir=W:\;Drive r={Driver do
Microsoft Excel(*.xls)};DriverId=790;FIL=excel 8.0;MaxBufferSize=2048;" _
), Array( _

"MaxScanRows=20;PageTimeout=5;ReadOnly=1;SafeTrans actions=0;Threads=3;UID=admin;UserCommitSync=Yes;" _
)), Destination:=Range("$A$1")).QueryTable
.CommandText = Array( _
"SELECT `Sheet1$`.*" & Chr(10) & "FROM `W:\INI_Tel_Data`.`Sheet1$`
`Sheet1$`" _
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_TCM_Tel_Data"
.Refresh BackgroundQuery:=False
End With


When this runs, it gets the data OK, but an unwanted autofilter is created,
which changes the data in 2 number columns in the first row:

01/04/2009 00:29:26 02890839200 288513 00:00:04 F5 F6
01/04/2009 05:56:29 02088813556 288596 00:00:14 14 0
01/04/2009 07:59:58 07814934347 288513 00:00:13 13 0

When this removed using

Cells(1, 6).AutoFilter

The Data in two of the cells is replaced by "F5" "F6"

Is there a way to stop this happening?

Thanks

Andrew



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Unwanted Querytable Autofilter on ODBC Import

Hi Jacob,

Many thanks for your reply.

Sorry, this does not remove the filter, and/or the filter is still
being created, when the data is loaded.

Thanks Again

Andrew



"Jacob Skaria" wrote:

I could not test this. Please try and feedback......

Replace Cells(1, 6).AutoFilter with

Activesheet.AutoFilterMode = False

If this post helps click Yes
---------------
Jacob Skaria


"CallScripter Dev" wrote:

Hi,

I am using the following vba code to import data from an external Excel
workbook, into a another reporting worksheet:

Sheets("CV TEL Data").Select

Rows("1:1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents

Cells.Select
Selection.ClearContents


With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DBQ=W:\INI_Tel_Data.xls;DefaultDir=W:\;Drive r={Driver do
Microsoft Excel(*.xls)};DriverId=790;FIL=excel 8.0;MaxBufferSize=2048;" _
), Array( _

"MaxScanRows=20;PageTimeout=5;ReadOnly=1;SafeTrans actions=0;Threads=3;UID=admin;UserCommitSync=Yes;" _
)), Destination:=Range("$A$1")).QueryTable
.CommandText = Array( _
"SELECT `Sheet1$`.*" & Chr(10) & "FROM `W:\INI_Tel_Data`.`Sheet1$`
`Sheet1$`" _
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_TCM_Tel_Data"
.Refresh BackgroundQuery:=False
End With


When this runs, it gets the data OK, but an unwanted autofilter is created,
which changes the data in 2 number columns in the first row:

01/04/2009 00:29:26 02890839200 288513 00:00:04 F5 F6
01/04/2009 05:56:29 02088813556 288596 00:00:14 14 0
01/04/2009 07:59:58 07814934347 288513 00:00:13 13 0

When this removed using

Cells(1, 6).AutoFilter

The Data in two of the cells is replaced by "F5" "F6"

Is there a way to stop this happening?

Thanks

Andrew



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Unwanted Querytable Autofilter on ODBC Import

Are you sure the filter wan't on before you ran the macro?

Try putting in the following to make sure filters arre removed before
running macro

Worksheets("CV TEL Data").ShowAllData

"CallScripter Dev" wrote:

Hi,

I am using the following vba code to import data from an external Excel
workbook, into a another reporting worksheet:

Sheets("CV TEL Data").Select

Rows("1:1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents

Cells.Select
Selection.ClearContents


With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DBQ=W:\INI_Tel_Data.xls;DefaultDir=W:\;Drive r={Driver do
Microsoft Excel(*.xls)};DriverId=790;FIL=excel 8.0;MaxBufferSize=2048;" _
), Array( _

"MaxScanRows=20;PageTimeout=5;ReadOnly=1;SafeTrans actions=0;Threads=3;UID=admin;UserCommitSync=Yes;" _
)), Destination:=Range("$A$1")).QueryTable
.CommandText = Array( _
"SELECT `Sheet1$`.*" & Chr(10) & "FROM `W:\INI_Tel_Data`.`Sheet1$`
`Sheet1$`" _
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_TCM_Tel_Data"
.Refresh BackgroundQuery:=False
End With


When this runs, it gets the data OK, but an unwanted autofilter is created,
which changes the data in 2 number columns in the first row:

01/04/2009 00:29:26 02890839200 288513 00:00:04 F5 F6
01/04/2009 05:56:29 02088813556 288596 00:00:14 14 0
01/04/2009 07:59:58 07814934347 288513 00:00:13 13 0

When this removed using

Cells(1, 6).AutoFilter

The Data in two of the cells is replaced by "F5" "F6"

Is there a way to stop this happening?

Thanks

Andrew



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Unwanted Querytable Autofilter on ODBC Import

Hi Joel,

Many thanks for your reply.

I am fairly certain that the filter is not there before the macro is
run.

To confirm, I deleted the old data and querytable before running.

When I add "Worksheets("CV TEL Data").ShowAllData" as you suggested,
I get a Run-time error 1004 ShowAllData mehod of worksheet class failed.

I am using Excel 2007, not sure if this makes a difference.

Thanks Again

Andrew


"joel" wrote:

Are you sure the filter wan't on before you ran the macro?

Try putting in the following to make sure filters arre removed before
running macro

Worksheets("CV TEL Data").ShowAllData

"CallScripter Dev" wrote:

Hi,

I am using the following vba code to import data from an external Excel
workbook, into a another reporting worksheet:

Sheets("CV TEL Data").Select

Rows("1:1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents

Cells.Select
Selection.ClearContents


With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DBQ=W:\INI_Tel_Data.xls;DefaultDir=W:\;Drive r={Driver do
Microsoft Excel(*.xls)};DriverId=790;FIL=excel 8.0;MaxBufferSize=2048;" _
), Array( _

"MaxScanRows=20;PageTimeout=5;ReadOnly=1;SafeTrans actions=0;Threads=3;UID=admin;UserCommitSync=Yes;" _
)), Destination:=Range("$A$1")).QueryTable
.CommandText = Array( _
"SELECT `Sheet1$`.*" & Chr(10) & "FROM `W:\INI_Tel_Data`.`Sheet1$`
`Sheet1$`" _
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_TCM_Tel_Data"
.Refresh BackgroundQuery:=False
End With


When this runs, it gets the data OK, but an unwanted autofilter is created,
which changes the data in 2 number columns in the first row:

01/04/2009 00:29:26 02890839200 288513 00:00:04 F5 F6
01/04/2009 05:56:29 02088813556 288596 00:00:14 14 0
01/04/2009 07:59:58 07814934347 288513 00:00:13 13 0

When this removed using

Cells(1, 6).AutoFilter

The Data in two of the cells is replaced by "F5" "F6"

Is there a way to stop this happening?

Thanks

Andrew





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
QueryTable import keeps appending instead of overwriting. David Excel Programming 3 October 28th 08 02:22 PM
QueryTable Null Import Quirk / Problem Mike Iacovou Excel Programming 0 July 20th 07 10:38 PM
ODBC / OLE DB QueryTable Editor Add-In for Excel Rob van Gelder[_4_] Excel Programming 0 December 18th 04 03:55 AM
Changing only source file of pre-existing text import QueryTable? EBrowne Excel Programming 3 August 23rd 04 03:31 AM
Using Querytable.add to import data from a closed workbook Markus Stolle[_5_] Excel Programming 8 August 3rd 04 08:51 PM


All times are GMT +1. The time now is 02:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"