Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically sum a filter


Hi

I have an excel spreadsheet with 2 buttons to filter and unfilter th
data by part number. How can I get it to also show me a total number i
stock for that part number. i.e When I search for part numbe
VCP/3301/MP the spreadsheet shows say 3020 in 1 location and say 250
in another. I need it to automatically show me a total for thi
product.

The current code is as follows:-

Option Explicit

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

Private Sub CommandButton2_Click()
With Worksheets("Inventory")
If .AutoFilterMode Then
If .FilterMode Then
.ShowAllData
End If
End If
End With
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Column = 6 Or .Column = 9 Or .Column = 10 Then
If IsNumeric(.Value) Or .HasFormula = True Then
Application.EnableEvents = False
Range("F" & Target.Row).Value = Range("K"
Target.Row).Value + Range("F" & Target.Row).Value
Application.EnableEvents = True
End If
End If
End With
End Sub

mack

--
mack
-----------------------------------------------------------------------
macke's Profile: http://www.excelforum.com/member.php...fo&userid=3244
View this thread: http://www.excelforum.com/showthread.php?threadid=53370

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Automatically sum a filter

=subtotal(9,C2:C2000)

would give you the sum of the visible items in the filter for values in
column C (as an example).

In code you can use

mysum = application.Subtotal(9,Activesheet.Autofilter.Rang e.Columns(3))

Not sure how the code you show relates to the question asked.

--
Regards,
Tom Ogilvy


"macke" wrote:


Hi

I have an excel spreadsheet with 2 buttons to filter and unfilter the
data by part number. How can I get it to also show me a total number in
stock for that part number. i.e When I search for part number
VCP/3301/MP the spreadsheet shows say 3020 in 1 location and say 2503
in another. I need it to automatically show me a total for this
product.

The current code is as follows:-

Option Explicit

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

Private Sub CommandButton2_Click()
With Worksheets("Inventory")
If .AutoFilterMode Then
If .FilterMode Then
.ShowAllData
End If
End If
End With
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Column = 6 Or .Column = 9 Or .Column = 10 Then
If IsNumeric(.Value) Or .HasFormula = True Then
Application.EnableEvents = False
Range("F" & Target.Row).Value = Range("K" &
Target.Row).Value + Range("F" & Target.Row).Value
Application.EnableEvents = True
End If
End If
End With
End Sub

macke


--
macke
------------------------------------------------------------------------
macke's Profile: http://www.excelforum.com/member.php...o&userid=32445
View this thread: http://www.excelforum.com/showthread...hreadid=533703


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically sum a filter


brilliant that works

Thank you

mack

--
mack
-----------------------------------------------------------------------
macke's Profile: http://www.excelforum.com/member.php...fo&userid=3244
View this thread: http://www.excelforum.com/showthread.php?threadid=53370

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
Can i get advanced filter to automatically refresh RichCovo Excel Worksheet Functions 3 April 5th 23 01:16 PM
Can you automatically filter for unique records? hankinator Excel Worksheet Functions 3 August 9th 06 08:40 PM
Filter data automatically by input Bunson Excel Worksheet Functions 2 May 28th 06 08:23 PM
automatically filter for unique records... or other suggestions Lila Excel Worksheet Functions 3 February 9th 06 10:52 PM
Can I automatically hide or filter a row? RJQMAN Excel Worksheet Functions 6 July 7th 05 03:49 PM


All times are GMT +1. The time now is 11:23 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"