Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting rows with specific values whatzzup Excel Discussion (Misc queries) 1 July 6th 06 10:35 AM
Deleting rows after a specific Value Steel Monkey[_6_] Excel Programming 2 June 2nd 06 01:48 AM
Deleting Specific Rows ScaffoldingDepot Excel Discussion (Misc queries) 2 May 4th 05 04:08 PM
Deleting specific rows Matt[_20_] Excel Programming 3 November 13th 03 10:41 PM
Deleting rows with specific value from row 1 to 200 solo_razor[_23_] Excel Programming 1 November 4th 03 07:56 AM


All times are GMT +1. The time now is 05:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"