Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Filter and delete

Posted on 2016-11-16
6
Medium Priority
?
32 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

670 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