![]() |
Need Help with marco and autofilter
i'm trying to use a marco to automatically filter my data so that it i reduced to the relivant rows then create a series of graph to explan this data but all i keep getting is "runtime error - 438." i beliv that it has something to do with the data already being filtered. an help would be grea -- Bilbotubbin ----------------------------------------------------------------------- Bilbotubbins's Profile: http://www.excelforum.com/member.php...fo&userid=2591 View this thread: http://www.excelforum.com/showthread.php?threadid=39286 |
Need Help with marco and autofilter
Hi Bilbotubbins,
Post the problematic code. --- Regards, Norman "Bilbotubbins" wrote in message news:Bilbotubbins.1t8nyt_1123157145.3895@excelforu m-nospam.com... i'm trying to use a marco to automatically filter my data so that it is reduced to the relivant rows then create a series of graph to explane this data but all i keep getting is "runtime error - 438." i belive that it has something to do with the data already being filtered. any help would be great -- Bilbotubbins ------------------------------------------------------------------------ Bilbotubbins's Profile: http://www.excelforum.com/member.php...o&userid=25910 View this thread: http://www.excelforum.com/showthread...hreadid=392861 |
Need Help with marco and autofilter
Sub Macro1() ' ' Macro1 Macro ' Macro recorded 4/08/2005 by Tubby ' ' Sheets("Sheet1").Select Selection.AutoFilter Field:=1, Criteria1:="Plumber" Range("B21,B2:B3,D2:D3").Select Range("D2").Activate Charts.Add ActiveChart.ChartType = xlPie ActiveChart.SetSourceDat Source:=Sheets("Sheet1").Range("B21,B2:B3,D2:D3") ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1" End Sub Sub testplu() ' ' testplu Macro ' Macro recorded 4/08/2005 by Tubby ' ' Sheets("Sheet1").Select ActiveWindow.SmallScroll Down:=27 Selection.AutoFilter Field:=1, Criteria1:="Plumber" Range("B41:B42,D41:D42").Select Range("D41").Activate Charts.Add ActiveChart.ChartType = xlPie ActiveChart.SetSourceDat Source:=Sheets("Sheet1").Range("B41:B42,D41:D42") ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1" ActiveSheet.Shapes("Chart 25").IncrementLeft -165# ActiveSheet.Shapes("Chart 25").IncrementTop -399.75 Windows("Rental Maintenance.xls").SmallScroll Down:=21 ActiveWindow.Visible = False Windows("Rental Maintenance.xls").Activate Selection.AutoFilter Field:=1 End Su -- Bilbotubbin ----------------------------------------------------------------------- Bilbotubbins's Profile: http://www.excelforum.com/member.php...fo&userid=2591 View this thread: http://www.excelforum.com/showthread.php?threadid=39286 |
Need Help with marco and autofilter
Hi, Bilbotubbins,
What line is hghlighted when you get the error message? --- Regards, Norman "Bilbotubbins" wrote in message news:Bilbotubbins.1t9tmd_1123211124.4014@excelforu m-nospam.com... Sub Macro1() ' ' Macro1 Macro ' Macro recorded 4/08/2005 by Tubby ' ' Sheets("Sheet1").Select Selection.AutoFilter Field:=1, Criteria1:="Plumber" Range("B21,B2:B3,D2:D3").Select Range("D2").Activate Charts.Add ActiveChart.ChartType = xlPie ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B21,B2:B3,D2:D3") ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1" End Sub Sub testplu() ' ' testplu Macro ' Macro recorded 4/08/2005 by Tubby ' ' Sheets("Sheet1").Select ActiveWindow.SmallScroll Down:=27 Selection.AutoFilter Field:=1, Criteria1:="Plumber" Range("B41:B42,D41:D42").Select Range("D41").Activate Charts.Add ActiveChart.ChartType = xlPie ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B41:B42,D41:D42") ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1" ActiveSheet.Shapes("Chart 25").IncrementLeft -165# ActiveSheet.Shapes("Chart 25").IncrementTop -399.75 Windows("Rental Maintenance.xls").SmallScroll Down:=21 ActiveWindow.Visible = False Windows("Rental Maintenance.xls").Activate Selection.AutoFilter Field:=1 End Sub -- Bilbotubbins ------------------------------------------------------------------------ Bilbotubbins's Profile: http://www.excelforum.com/member.php...o&userid=25910 View this thread: http://www.excelforum.com/showthread...hreadid=392861 |
Need Help with marco and autofilter
Hi Bilbotubbins,
I have not attempted to reproduce your data environment, but If I guess that your error occurs on the line: Selection.AutoFilter Field:=1, Criteria1:="Plumber" in the TestPlu macro (after you have run Macro1), then your error is caused by the fact that, at that moment, the selection is a chart object (created in Macro1). A chart object does not have an autofilter method, hence your encountered error. To resolve the problem, replace 'Selection' in the above line with a range object corresponding to any cell(s) in the table to be autofiltered. For example, if the table incldes the A1 cell then, replacing the problem line with: Range("A1")..AutoFilter Field:=1, Criteria1:="Plumber" should resolve your immediate problem, If my guess is wrong, post back indicating the line which is highlighted when the error occurs. --- Regards, Norman "Bilbotubbins" wrote in message news:Bilbotubbins.1t9tmd_1123211124.4014@excelforu m-nospam.com... Sub Macro1() ' ' Macro1 Macro ' Macro recorded 4/08/2005 by Tubby ' ' Sheets("Sheet1").Select Selection.AutoFilter Field:=1, Criteria1:="Plumber" Range("B21,B2:B3,D2:D3").Select Range("D2").Activate Charts.Add ActiveChart.ChartType = xlPie ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B21,B2:B3,D2:D3") ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1" End Sub Sub testplu() ' ' testplu Macro ' Macro recorded 4/08/2005 by Tubby ' ' Sheets("Sheet1").Select ActiveWindow.SmallScroll Down:=27 Selection.AutoFilter Field:=1, Criteria1:="Plumber" Range("B41:B42,D41:D42").Select Range("D41").Activate Charts.Add ActiveChart.ChartType = xlPie ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B41:B42,D41:D42") ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1" ActiveSheet.Shapes("Chart 25").IncrementLeft -165# ActiveSheet.Shapes("Chart 25").IncrementTop -399.75 Windows("Rental Maintenance.xls").SmallScroll Down:=21 ActiveWindow.Visible = False Windows("Rental Maintenance.xls").Activate Selection.AutoFilter Field:=1 End Sub -- Bilbotubbins ------------------------------------------------------------------------ Bilbotubbins's Profile: http://www.excelforum.com/member.php...o&userid=25910 View this thread: http://www.excelforum.com/showthread...hreadid=392861 |
All times are GMT +1. The time now is 06:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com