Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel spreadsheet

Status
Not open for further replies.

grierfield

Technical User
Dec 18, 2002
55
US
I have a spreadsheet with 12 columns and hundreds of rows of data.

New rows (records) of data are constantly being added.

One column has 5 different data specification.

If I do an auto filter to show information for one of the 5 data types in the specific column and save the steps as a Macro – --- when more data is added – the macro does not pick up the new data.

I would like to place 5 buttons on the spreadsheet with the name of each of the 5 specific data types so that when one clicks the button it will run the auto filter macro and also includes new data that was added.

thanks
 




Hi,

Yes, it's me! I misdirected your to this forum, because your question seemed like it fit here.

But in reality, it is a VBA CODE question that belongs in forum707, rather than here, which would address the AutoFilter spreadsheet feature or in an Access forum that has nothing to do with Excel.

Please post your code in Forum707, when you repost.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
This is a common problem in recorded code. The code probably refers to a specific range for the autofilter (something like Range("A1:L500")) and that doesn't take into account newly added rows.

If you need further help editing the code, please repost this VBA-specific question in forum707.

Also, provide the code that you have recorded.


[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
grumble grumble

I'm just too slow today....

[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/23/2009 by CHP
'

'
Range("H2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=8, Criteria1:="MRSA"
End Sub

Above is the macro code that selected “MRSA” using auto filter – now there were 1205 instances of “MRSA” in the spreadsheet. When we add additional “MRSA” to the spreadsheet – I would like for users to just run the macro and filter the “MRSA” from the other identifiers in that column.
 

Code:
Sub FilterValue(sValue As String)
    With ActiveSheet
        If Not .AutoFilterMode Then .[H2].AutoFilter
        
        .Range("H2").AutoFilter _
            Field:=8, _
            Criteria1:=sValue
    End With
End Sub

Call from the button click event, supplying the appropriate value.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 



...oops!!!

This should all be in Forum707.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
thanks very much - i will try that - thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top