Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default OLE Excel AutoFilter

Is there a way to filter out only columns that have values? (NonBlanks)
from Filter?

[highlight="perl"]
use Win32::OLE;
use strict;

my $EXCEL = Win32::OLE-new('Excel.Application','Quit');
$EXCEL-{'Visible'} = 1;

my $Workbook = $EXCEL-Workbooks-Open("C:\\Ex\\Test3.xls");

my $SheetSelect = $Workbook-Sheets("A");
$SheetSelect-Select;
my $Current_Sheet = $Workbook - ActiveSheet;

# set bold & color
my $row=2;
my $value = $SheetSelect - Range("B".$row) - {'Value'};
while($value =~ /\w+/) {
my $colorRange = $SheetSelect-Range("B".$row.":C".$row);
$colorRange-{Font}-{Bold} = 1 ;
$colorRange-Interior-{ColorIndex} = 4;

$row++;
$value = $SheetSelect - Range("B".$row) - {'Value'};
}

# set auto fit & filter (display drop down menu list)
my $autoFit = $SheetSelect-Range("B2:C40");;
$autoFit-Columns()-Autofit();
###This is part where I am having problem.. I want to show only
NonBlanks
$autoFit-Columns()-AutoFilter("1","(NonBlanks)");
#this will diplay the rows have 100 as the value
# $autoFit-Columns()-AutoFilter("1","100");


## Save
$EXCEL-ActiveWorkbook-Save();
$Workbook-Save();
$Workbook-Quit();
Win32::OLE-FreeUnusedLibraries();
[/highlight]

Code:
Function AutoFilter([Field], [Criteria1], [Operator As
XlAutoFilterOperator = xlAnd], [Criteria2], [VisibleDropDown])
Any help? Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default OLE Excel AutoFilter

Kenny,
The easiest to get an idea of the methods/object required is record a macro
in Excel first.
I get :
Selection.AutoFilter Field:=1, Criteria1:="<"
So for you I guess something like :
$autoFit-Columns()-AutoFilter("1","<");

NickHK

"Kenny" wrote in message
oups.com...
Is there a way to filter out only columns that have values? (NonBlanks)
from Filter?

[highlight="perl"]
use Win32::OLE;
use strict;

my $EXCEL = Win32::OLE-new('Excel.Application','Quit');
$EXCEL-{'Visible'} = 1;

my $Workbook = $EXCEL-Workbooks-Open("C:\\Ex\\Test3.xls");

my $SheetSelect = $Workbook-Sheets("A");
$SheetSelect-Select;
my $Current_Sheet = $Workbook - ActiveSheet;

# set bold & color
my $row=2;
my $value = $SheetSelect - Range("B".$row) - {'Value'};
while($value =~ /\w+/) {
my $colorRange = $SheetSelect-Range("B".$row.":C".$row);
$colorRange-{Font}-{Bold} = 1 ;
$colorRange-Interior-{ColorIndex} = 4;

$row++;
$value = $SheetSelect - Range("B".$row) - {'Value'};
}

# set auto fit & filter (display drop down menu list)
my $autoFit = $SheetSelect-Range("B2:C40");;
$autoFit-Columns()-Autofit();
###This is part where I am having problem.. I want to show only
NonBlanks
$autoFit-Columns()-AutoFilter("1","(NonBlanks)");
#this will diplay the rows have 100 as the value
# $autoFit-Columns()-AutoFilter("1","100");


## Save
$EXCEL-ActiveWorkbook-Save();
$Workbook-Save();
$Workbook-Quit();
Win32::OLE-FreeUnusedLibraries();
[/highlight]

Code:
 Function AutoFilter([Field], [Criteria1], [Operator As
 XlAutoFilterOperator = xlAnd], [Criteria2], [VisibleDropDown])

Any help? Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default OLE Excel AutoFilter

Thanks NickHK. That's what I need.

NickHK wrote:
Kenny,
The easiest to get an idea of the methods/object required is record a macro
in Excel first.
I get :
Selection.AutoFilter Field:=1, Criteria1:="<"
So for you I guess something like :
$autoFit-Columns()-AutoFilter("1","<");

NickHK

"Kenny" wrote in message
oups.com...
Is there a way to filter out only columns that have values? (NonBlanks)
from Filter?

[highlight="perl"]
use Win32::OLE;
use strict;

my $EXCEL = Win32::OLE-new('Excel.Application','Quit');
$EXCEL-{'Visible'} = 1;

my $Workbook = $EXCEL-Workbooks-Open("C:\\Ex\\Test3.xls");

my $SheetSelect = $Workbook-Sheets("A");
$SheetSelect-Select;
my $Current_Sheet = $Workbook - ActiveSheet;

# set bold & color
my $row=2;
my $value = $SheetSelect - Range("B".$row) - {'Value'};
while($value =~ /\w+/) {
my $colorRange = $SheetSelect-Range("B".$row.":C".$row);
$colorRange-{Font}-{Bold} = 1 ;
$colorRange-Interior-{ColorIndex} = 4;

$row++;
$value = $SheetSelect - Range("B".$row) - {'Value'};
}

# set auto fit & filter (display drop down menu list)
my $autoFit = $SheetSelect-Range("B2:C40");;
$autoFit-Columns()-Autofit();
###This is part where I am having problem.. I want to show only
NonBlanks
$autoFit-Columns()-AutoFilter("1","(NonBlanks)");
#this will diplay the rows have 100 as the value
# $autoFit-Columns()-AutoFilter("1","100");


## Save
$EXCEL-ActiveWorkbook-Save();
$Workbook-Save();
$Workbook-Quit();
Win32::OLE-FreeUnusedLibraries();
[/highlight]

Code:
  Function AutoFilter([Field], [Criteria1], [Operator As
  XlAutoFilterOperator = xlAnd], [Criteria2], [VisibleDropDown])
 

Any help? Thanks.


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
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
2007 Autofilter worse than 2003 Autofilter jsky Excel Discussion (Misc queries) 9 October 31st 07 12:14 AM
How to Sort within AutoFilter with Protection on (and AutoFilter . giblon Excel Discussion (Misc queries) 1 February 16th 06 12:23 PM


All times are GMT +1. The time now is 04:03 AM.

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"