Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Autofilter used programmaticaly causes error

Hi,
during migration from Office 2003 on Windows 2000 to Office 2007 on Windows
Vista I've encountered strange error in one worksheet programmed years ago.

Code is as follows:

Workbooks.OpenText
Filename:="D:\_glowapps\Transfer\GT\Static\MX_Repo rts\tr_fx_fwd_p.prn" _
, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited,
TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=True _
, Comma:=False, Space:=False, Other:=False,
FieldInfo:=Array(Array(1, 1) _
, Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1),
Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1),
Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1),
Array(20, 1), Array(21, 1), _
Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26,
1), Array(27, 1), Array( _
28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1),
Array(33, 1), Array(34, 1), _
Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39,
1), Array(40, 1), Array( _
41, 1), Array(42, 1), Array(43, 1), Array(44, 1), Array(45, 1))


Rows("1:1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=44, Criteria1:="COMMODITY"
Selection.AutoFilter Field:=34, Criteria1:="PRAGUE"
Selection.AutoFilter Field:=15, Criteria1:="<BNK", Operator:=xlAnd
Cells.Select
Selection.Copy
Windows("KPkomodity.xls").Activate
Sheets("Import").Select
Range("A1").Select
ActiveSheet.Paste

On the last line error appears - it's Runtime Error 1004 - The information
cannost be pasted because the Copy area and the paste area are not the same
size and shape.

If I comment all the lines beginning with "Sellection.AutoFilter",
everything is O.K., but pasted reccords are not filtered. If I uncomment
them, error appears.

I'll be gratefull for any advice how to avoid this error and paste filtered
records.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Autofilter used programmaticaly causes error

Please try the below changes

Rows("1:1").Select

Range("A1").activate
Selection.AutoFilter
Selection.AutoFilter Field:=44, Criteria1:="COMMODITY"
Selection.AutoFilter Field:=34, Criteria1:="PRAGUE"
Selection.AutoFilter Field:=15, Criteria1:="<BNK", Operator:=xlAnd
Cells.Select
Selection.Copy

' Windows("KPkomodity.xls").Activate
Workbooks("KPkomodity.xls").Activate
Sheets("Import").Select
Range("A1").Select
ActiveSheet.Paste


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Autofilter used programmaticaly causes error


Two things you can try...

Change:
Range("A1").Select
ActiveSheet.Paste
To:
Range("A1").PasteSpecial
Or:
Cells.Paste
'--

Are you glad you "upgraded" ?
'--
Jim Cone
Portland, Oregon USA



"Jarda Beran"

wrote in message
Hi,
during migration from Office 2003 on Windows 2000 to Office 2007 on Windows
Vista I've encountered strange error in one worksheet programmed years ago.

Code is as follows:

Workbooks.OpenText
Filename:="D:\_glowapps\Transfer\GT\Static\MX_Repo rts\tr_fx_fwd_p.prn" _
, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited,
TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=True _
, Comma:=False, Space:=False, Other:=False,
FieldInfo:=Array(Array(1, 1) _
, Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1),
Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1),
Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1),
Array(20, 1), Array(21, 1), _
Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26,
1), Array(27, 1), Array( _
28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1),
Array(33, 1), Array(34, 1), _
Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39,
1), Array(40, 1), Array( _
41, 1), Array(42, 1), Array(43, 1), Array(44, 1), Array(45, 1))


Rows("1:1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=44, Criteria1:="COMMODITY"
Selection.AutoFilter Field:=34, Criteria1:="PRAGUE"
Selection.AutoFilter Field:=15, Criteria1:="<BNK", Operator:=xlAnd
Cells.Select
Selection.Copy
Windows("KPkomodity.xls").Activate
Sheets("Import").Select
Range("A1").Select
ActiveSheet.Paste

On the last line error appears - it's Runtime Error 1004 - The information
cannost be pasted because the Copy area and the paste area are not the same
size and shape.

If I comment all the lines beginning with "Sellection.AutoFilter",
everything is O.K., but pasted reccords are not filtered. If I uncomment
them, error appears.

I'll be gratefull for any advice how to avoid this error and paste filtered
records.

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
How to Programmaticaly Delete or disable minimize and Maximise but Peter B[_2_] Excel Programming 0 January 15th 09 07:02 PM
Error 91 in Autofilter [email protected] Excel Programming 10 August 21st 08 08:01 PM
programmaticaly test more then 1000 excel files for "opening Errors" Robert[_28_] Excel Programming 2 December 23rd 04 10:49 PM
Solution: How to programmaticaly leave "edit mode" David Owens Excel Programming 2 September 3rd 04 03:09 PM
VBA Autofilter error in '97, not 2000 Foggy Excel Programming 3 April 3rd 04 03:57 AM


All times are GMT +1. The time now is 05:12 AM.

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

About Us

"It's about Microsoft Excel"