Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code for deleting rows with specific value
Hi,
Can some one assist me with the following: I want to create a macro that deletes all lines that contain a certain value in column A. For example A 1 EE 2 EE 3 EE 4 EE 5 DD 6 DD 7 DD 8 DD 9 DD 10 DD Does anyone knows which code to use for deleting all lines with "EE" om column A? All suggestions are mostly appreciated! Thanks a lot Regards, Robert |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code for deleting rows with specific value
Hi Robert, Try this... assume the data is in sheet1 (change as you like), amend this row if you want to delete different columns ("A") and data ="EE"). If Cells(R, "A").Value = "EE)" Then .Rows(R).Delete Sub DeleteRowEE() Application.ScreenUpdating = False Sheets("Sheet1").Select Range("a1").Select Dim R As Long With Worksheets("Sheet1") For R = .UsedRange.Rows.Count To 1 Step -1 If Cells(R, "A").Value = "EE)" Then .Rows(R).Delete Next End With Application.ScreenUpdating = True End Sub Hopr it helps P Robert wrote: Hi, Can some one assist me with the following: I want to create a macro that deletes all lines that contain a certain value in column A. For example A 1 EE 2 EE 3 EE 4 EE 5 DD 6 DD 7 DD 8 DD 9 DD 10 DD Does anyone knows which code to use for deleting all lines with "EE" om column A? All suggestions are mostly appreciated! Thanks a lot Regards, Robert |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code for deleting rows with specific value
Can you also tell me how to refer to refer to another sheet (in which
the rows are located)? say for example "Sheet2" contains the data and the command buttow will be put in "Sheet1" Thanks again Robert Tom Ogilvy schreef: Sub DeleteRows() Dim rng as Range set rng = columns(1).Find("EE") if not rng is nothing then do rng.EntireRow.Delete set rng = columns(1).Find("EE") Loop while not rng is nothing End if End Sub -- Regards, Tom Ogilvy "Robert" wrote: Hi, Can some one assist me with the following: I want to create a macro that deletes all lines that contain a certain value in column A. For example A 1 EE 2 EE 3 EE 4 EE 5 DD 6 DD 7 DD 8 DD 9 DD 10 DD Does anyone knows which code to use for deleting all lines with "EE" om column A? All suggestions are mostly appreciated! Thanks a lot Regards, Robert |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting rows with specific values | Excel Discussion (Misc queries) | |||
Deleting rows after a specific Value | Excel Programming | |||
Deleting Specific Rows | Excel Discussion (Misc queries) | |||
Deleting specific rows | Excel Programming | |||
Deleting rows with specific value from row 1 to 200 | Excel Programming |