Solved

Filter and delete

Posted on 2016-11-16
6
14 Views
Last Modified: 2016-11-17
Can an expert provide me with VBA code that will filter then delete the data in that range but only that range.

So the range is A-N. I need to filter Column ‘I’ with Credit and then delete anything that now appears in that filter then unfilter.

There is a pivot table in cells R-S and I do not want to delete this.

I am using below code on other sheets where there is no pivot and this works fine but it deletes entire row.

Thank you in advance
0
Comment
Question by:Jagwarman
  • 5
6 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41890960
Hi,

pls try

Sub Macro1()
'
' Macro1 Macro
'
   Set c = Range("I" & Rows.Count)
   For lCol = 1 To WorksheetFunction.CountIf(Range("I:I"), "Credit")
        Set c = Range("I:I").Find(What:="Credit", LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False)
            Range("A" & c.Row).Resize(, 14).Delete Shift:=xlShiftUp
   Next lCol
 
End Sub

Open in new window

Regards
0
 

Author Comment

by:Jagwarman
ID: 41890989
I don't understand it is giving me error "You cannot move a part of a pivot table and yet you are only looking upto 14 and the pivot is in 18 and 19. Any ideas?


 Range("A" & c.Row).Resize(, 14).Delete Shift:=xlShiftUp
0
 

Author Comment

by:Jagwarman
ID: 41891023
what I notice is if I right click my mouse on the range it does not show 'Delete' which would allow me to Shift cells UP/Down/Right/Left it only give me the option to Delete Row ???
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Jagwarman
ID: 41891030
reading up on this on Google looks like it's not possible it says you can only delete entire row when in filter mode. So now I have the problem I only want to delete from A-n where Credit is in column 'I'

What is the way around this?

Sorry Rgonzo, soon I will be gone
0
 

Author Comment

by:Jagwarman
ID: 41891034
Rgonzo, I think it is time for me to retire. Of course it was me, I just needed to remove the filter.

Regards
Jagwarman
0
 

Author Closing Comment

by:Jagwarman
ID: 41891035
:-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now