Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all, i have many rows with the same number in column A and i am
filtering column F for the criteria "ZA-T-M-*" which is working fine. However i need somehow to delete all rows with the same number in column A. The second last row has ZA-T-M-* in it so all rows with instances of "A15862" in column "A" muist be deleted. Can someone please help. Thank you in advance... A B C D E F A15862 Creation K5210 7118410 UPHOLSTERY EI- A15862 Creation K5210 7118410 UPHOLSTERY E-M A15862 Creation K5210 7139700 UPHOLSTERY EI-A15862 Creation K5210 7139700 UPHOLSTERY FZ-A15862 Creation L2 A15862 Creation TI- A15862 Creation ZA-T-M-1 A15862 Creation Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Les
Apply a second filter to column A for whatever number you wish to delete and then delete them. When I do something like this, I usually set two range objects - one for the autofilter range, and one for the data range (ie the same less header row), and then use SpecialCells method to delete only the visible cells. In xl2002 and 2003 you don't have to worry about using the SpecialMethod, but it does make your code absolutely clear what you are doing (and intending to do). Something like: With rng .Autofilter Field:=1, Criteria1:=<Your Number Here rng2.SpecialCells(xlCellTypeVisible).EntireRow.Del ete End With Does this give you enough detail to work up a solution? Best regards Richard Les Stout wrote: Hi all, i have many rows with the same number in column A and i am filtering column F for the criteria "ZA-T-M-*" which is working fine. However i need somehow to delete all rows with the same number in column A. The second last row has ZA-T-M-* in it so all rows with instances of "A15862" in column "A" muist be deleted. Can someone please help. Thank you in advance... A B C D E F A15862 Creation K5210 7118410 UPHOLSTERY EI- A15862 Creation K5210 7118410 UPHOLSTERY E-M A15862 Creation K5210 7139700 UPHOLSTERY EI-A15862 Creation K5210 7139700 UPHOLSTERY FZ-A15862 Creation L2 A15862 Creation TI- A15862 Creation ZA-T-M-1 A15862 Creation Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Richard,
Yes i think so thanks for your input... Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, i have the following code which works great, i just do not know how
to delete all instances of the number in column "A". Should i copy and save the filtered out numbers and then delete all instances using vlookup ? Sub FilterAndErase() ' ' Application.ScreenUpdating = False ' Rows("1:19").Delete Shift:=xlUp Rows("1:1").AutoFilter '************ Filter the field gAMS Created by **************** Dim Rng As Range Dim i As Long Dim myArr As Variant Dim myRows As Long myRows = Cells(Application.Rows.Count, 1).End(xlUp).Row myArr = Array("=*za-t-m-**") For i = LBound(myArr) To UBound(myArr) ActiveSheet.Range("A1:P" & myRows).AutoFilter Field:=8, Criteria1:=myArr(i) With ActiveSheet.AutoFilter.Range Set Rng = Nothing On Error Resume Next Set Rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _ .SpecialCells(xlCellTypeVisible) On Error GoTo 0 If Not Rng Is Nothing Then Rng.EntireRow.Delete End With Next i ActiveSheet.AutoFilterMode = False End sub Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you wanting to delete rows with ("=*za-t-m-**") in them? Or keep this
row and delete all others with the same numer in A? Mike F "Les Stout" wrote in message ... Hi, i have the following code which works great, i just do not know how to delete all instances of the number in column "A". Should i copy and save the filtered out numbers and then delete all instances using vlookup ? Sub FilterAndErase() ' ' Application.ScreenUpdating = False ' Rows("1:19").Delete Shift:=xlUp Rows("1:1").AutoFilter '************ Filter the field gAMS Created by **************** Dim Rng As Range Dim i As Long Dim myArr As Variant Dim myRows As Long myRows = Cells(Application.Rows.Count, 1).End(xlUp).Row myArr = Array("=*za-t-m-**") For i = LBound(myArr) To UBound(myArr) ActiveSheet.Range("A1:P" & myRows).AutoFilter Field:=8, Criteria1:=myArr(i) With ActiveSheet.AutoFilter.Range Set Rng = Nothing On Error Resume Next Set Rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _ .SpecialCells(xlCellTypeVisible) On Error GoTo 0 If Not Rng Is Nothing Then Rng.EntireRow.Delete End With Next i ActiveSheet.AutoFilterMode = False End sub Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mike, I filter for ("=*za-t-m-**") and want to delete the row, which
i am managing with the code.. My problem is however that i have to delete all of the rows with the same number for this row in column "A" which is anything from 1 to 50 rows. Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
filter and delete | Excel Discussion (Misc queries) | |||
Filter and Delete | Excel Worksheet Functions | |||
AFTER 8 SEC ON SPACEBAR I GOT A FILTER?DELETE IT? | Excel Discussion (Misc queries) | |||
Filter list and delete | Excel Discussion (Misc queries) | |||
filter and delete | Excel Worksheet Functions |