Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Frank, Your macro help is great. Say I want to do the same as steve but delet any rows that contain "XXX" anywhere in the field, so XXX is never alon but always adjacent to other text. Thanks in advance!! Frank Kabel Wrote: Hi Steve so you want to delete the row if either of these values is in colum B. Try Public Sub DeleteRows() Dim R As Long Dim C As Range Dim Rng As Range On Error GoTo EndMacro Application.ScreenUpdating = False Application.Calculation = xlCalculationManual If Selection.Rows.Count 1 Then Set Rng = Selection Else Set Rng = ActiveSheet.UsedRange.Rows End If For R = Rng.Rows.Count To 1 Step -1 If cells(r,"B").value = "WX" or _ cells(r,"B").value = "PAX" or _ cells(r,"B").value = "CUS" or _ Then Rng.Rows(R).EntireRow.Delete End If Next R -- Regards Frank Kabel Frankfurt, Germany Steve wrote: All right, i finally got it too work. i have one final question....How do I add multiple values. so that along w/ wx, it will also look for pax, cus, atc. once again I thank you all for your help. Steve -----Original Message----- Hi should work if you pasted this macro in a module of your current workbook (it should appear in the macro menu) You may have a look at the following site for more information how to use/install macros http://www.mvps.org/dmcritchie/excel/getstarted.htm -- Regards Frank Kabel Frankfurt, Germany wrote: First, let me apologize for my blatant ignorance. i tried copying and pasting it into module 4 after another macro i have in. Now i can't figure out how to either assign your macro to a button, or simply run it. when i go to the macro menu, it is not listed. thanks again for your time. steve -----Original Message----- Hi try the following Public Sub DeleteRows() Dim R As Long Dim C As Range Dim Rng As Range On Error GoTo EndMacro Application.ScreenUpdating = False Application.Calculation = xlCalculationManual If Selection.Rows.Count 1 Then Set Rng = Selection Else Set Rng = ActiveSheet.UsedRange.Rows End If For R = Rng.Rows.Count To 1 Step -1 If cells(r,"B").value = "WX" Then Rng.Rows(R).EntireRow.Delete End If Next R EndMacro: Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic End Sub -- Regards Frank Kabel Frankfurt, Germany Steve wrote: I am looking for a macro to delete an entire row, when there is a specific occurance in a cell. For instance, if cell b3 has the letters WX in it. I want to delete all of row b. I appreciate all your time and effort. Steve . -- as ----------------------------------------------------------------------- asf's Profile: http://www.excelforum.com/member.php...fo&userid=1493 View this thread: http://www.excelforum.com/showthread.php?threadid=19765 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete rows with specific text | New Users to Excel | |||
Delete specific rows of data | New Users to Excel | |||
Macro to delete rows containing specific data | New Users to Excel | |||
select and delete specific rows | Excel Discussion (Misc queries) | |||
Delete rows if specific criteria not met. | Excel Worksheet Functions |