Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Delete row if certain column of that row doesn't contain value

I need macro that would delete enire row if column D doesn't contain value

For example I have folowing worksheet:
A B C D
1 xx ee tt gg
2
3 ss aa dd
4 ss
5 11 33 55 66

After running macro this sheet should look like this

A B C D
1 xx ee tt gg
2 ss aa dd
3 11 33 55 66

Row's 2 and 5 are deleted becouse cells in column D where empty for those
rows.
Row's 3 and 5 are shifted up

I think this would do the trick for 1st row. Now I need to add if statement
that would determine which rows to delete ?

Rows("1").Delete Shift:=xlUp


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete row if certain column of that row doesn't contain value

Hi Mikus,

Try:
'===========================
Public Sub Tester03()
Dim rng As Range

Set rng = Intersect(ActiveSheet.UsedRange, Columns("D:D"))

On Error Resume Next
rng.SpecialCells(xlCellTypeBlanks).EntireRow.Delet e
On Error GoTo 0

End Sub
'===========================

Or use the built in autofilter feature.

---
Regards,
Norman



"Mikus" wrote in message
...
I need macro that would delete enire row if column D doesn't contain value

For example I have folowing worksheet:
A B C D
1 xx ee tt gg
2
3 ss aa dd
4 ss
5 11 33 55 66

After running macro this sheet should look like this

A B C D
1 xx ee tt gg
2 ss aa dd
3 11 33 55 66

Row's 2 and 5 are deleted becouse cells in column D where empty for those
rows.
Row's 3 and 5 are shifted up

I think this would do the trick for 1st row. Now I need to add if
statement
that would determine which rows to delete ?

Rows("1").Delete Shift:=xlUp




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Delete row if certain column of that row doesn't contain value

Thank you Norman, this works flawlessly

"Norman Jones" wrote:

Hi Mikus,

Try:
'===========================
Public Sub Tester03()
Dim rng As Range

Set rng = Intersect(ActiveSheet.UsedRange, Columns("D:D"))

On Error Resume Next
rng.SpecialCells(xlCellTypeBlanks).EntireRow.Delet e
On Error GoTo 0

End Sub
'===========================

Or use the built in autofilter feature.

---
Regards,
Norman



"Mikus" wrote in message
...
I need macro that would delete enire row if column D doesn't contain value

For example I have folowing worksheet:
A B C D
1 xx ee tt gg
2
3 ss aa dd
4 ss
5 11 33 55 66

After running macro this sheet should look like this

A B C D
1 xx ee tt gg
2 ss aa dd
3 11 33 55 66

Row's 2 and 5 are deleted becouse cells in column D where empty for those
rows.
Row's 3 and 5 are shifted up

I think this would do the trick for 1st row. Now I need to add if
statement
that would determine which rows to delete ?

Rows("1").Delete Shift:=xlUp





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete row if certain column of that row doesn't contain value


Thanks Norman!


--
Djmask
------------------------------------------------------------------------
Djmask's Profile: http://www.excelforum.com/member.php...o&userid=24414
View this thread: http://www.excelforum.com/showthread...hreadid=396801

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
Copy column header to next column, delete & delete every nth colum genehunter New Users to Excel 1 June 2nd 09 03:57 PM
delete cells column. Delete empty cells myshak Excel Worksheet Functions 0 March 9th 09 10:59 PM
Look for value in a column and delete Tempy Excel Programming 11 April 20th 05 03:02 PM
Delete All Rows That Column A value is not in Column A of Sheet2 [email protected] Excel Programming 2 September 3rd 04 09:13 PM
Delete row when zero in column b thru e Andy Excel Programming 4 May 28th 04 01:38 PM


All times are GMT +1. The time now is 09:05 AM.

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"