New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

Macro with filter data won't work! Can anyone help please!!

Macros, VBA, Excel Automation, etc.

Macro with filter data won't work! Can anyone help please!!

Postby alsac » Fri Mar 25, 2016 11:26 pm

sampleexcel.PNG



This is what I do and want:

I want to run a macro to filter my data which is located in cell (D), when the data is filtered I copy some stats that are contained in 9 different cells, then paste only the values to the right of the filtered data cell (D), after that I clear the filter and select the next cell (to the bottom) to be able to perform the same task in the future. I have tried with the relative reference on and off.

The outcome:

It performs the recorded macro, but only to that cell. Every time I run the macro it doesn't do it for the next cell and row.

Can anyone help? Thanks.

Code: Select all
Sub Combinationfilter()

    Selection.Copy
    ActiveSheet.Range("$A$3:$AJ$1955").AutoFilter Field:=4, Criteria1:= _
        "2-0,1-0,1-0"
    ActiveWindow.Panes(1).Activate
    Range("B2:J2").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveWindow.Panes(3).Activate
    Range("O1930").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
    Range("D1930").Select
    ActiveSheet.Range("$A$3:$AJ$1955").AutoFilter Field:=4
    ActiveCell.Offset(1, 0).Range("A1").Select
End Sub
  • 0

You do not have the required permissions to view the files attached to this post.
Last edited by pecoflyer on Sat Mar 26, 2016 3:57 am, edited 1 time in total.
Reason: Added code tags
alsac
Rookie
 
Posts: 1
Joined: Mar 25, 2016
Reputation: 0
Excel Version: Professional 2010

Re: Macro with filter data won't work! Can anyone help please!!

Postby pecoflyer » Sat Mar 26, 2016 3:57 am

Hi and welcome to the board.

As you can see, on each page in this forum there is a text in red font asking to wrap code with tags.
I will do it for you this time.

Thank you for following rules in the future


Also, although images are nice to look at, they cannot be worked with. Please post a sample sheet so help can be provided
  • 0

A relevant topic title helps get faster and more answers
pecoflyer
Moderator
 
Posts: 1274
Joined: Jan 24, 2012
Location: Belgium
Reputation: 39
Excel Version: 2003/2007/2010


Return to Macros and VBA Questions

Who is online

Users browsing this forum: No registered users and 33 guests