Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default Simple - Del empties

Hi,

I would like a code to delete empty rows based on column E (row 4 of the
table).

Using the recorded I apply a filter, use the filter to show the blank cells
from col E. At this point I dont know how to ask VB to select the first row
in table - it could be any row from 1 to 66500 depending on the contents.

How I get it to select the first empty row rather than having to ask it to
select a certain row as in the code below? Once selected I want to delete
all rows from there to the end.

Thanks

Sub DELROWS()
'
Rows("2:2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="="
Rows("9:9").Select
Range("B9").Activate
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.delete Shift:=xlUp
Selection.AutoFilter Field:=4
Rows("2:2").Select
Selection.AutoFilter
Range("B1").Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Simple - Del empties

for rw = range("E65000").Exd(xlup).Row to 4 step -1
if cells(rw,"E")="" then
rows(rw),delete
end if
next

"LiAD" wrote:

Hi,

I would like a code to delete empty rows based on column E (row 4 of the
table).

Using the recorded I apply a filter, use the filter to show the blank cells
from col E. At this point I dont know how to ask VB to select the first row
in table - it could be any row from 1 to 66500 depending on the contents.

How I get it to select the first empty row rather than having to ask it to
select a certain row as in the code below? Once selected I want to delete
all rows from there to the end.

Thanks

Sub DELROWS()
'
Rows("2:2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="="
Rows("9:9").Select
Range("B9").Activate
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.delete Shift:=xlUp
Selection.AutoFilter Field:=4
Rows("2:2").Select
Selection.AutoFilter
Range("B1").Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Simple - Del empties

Does this line of code do what you want?

Range("E4:E" & Rows.Count).SpecialCells(xlCellTypeBlanks).EntireR ow.Delete

--
Rick (MVP - Excel)


"LiAD" wrote in message
...
Hi,

I would like a code to delete empty rows based on column E (row 4 of the
table).

Using the recorded I apply a filter, use the filter to show the blank
cells
from col E. At this point I dont know how to ask VB to select the first
row
in table - it could be any row from 1 to 66500 depending on the contents.

How I get it to select the first empty row rather than having to ask it to
select a certain row as in the code below? Once selected I want to delete
all rows from there to the end.

Thanks

Sub DELROWS()
'
Rows("2:2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="="
Rows("9:9").Select
Range("B9").Activate
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.delete Shift:=xlUp
Selection.AutoFilter Field:=4
Rows("2:2").Select
Selection.AutoFilter
Range("B1").Select
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default Simple - Del empties

Perfect and simple.

Thanks

"Rick Rothstein" wrote:

Does this line of code do what you want?

Range("E4:E" & Rows.Count).SpecialCells(xlCellTypeBlanks).EntireR ow.Delete

--
Rick (MVP - Excel)


"LiAD" wrote in message
...
Hi,

I would like a code to delete empty rows based on column E (row 4 of the
table).

Using the recorded I apply a filter, use the filter to show the blank
cells
from col E. At this point I dont know how to ask VB to select the first
row
in table - it could be any row from 1 to 66500 depending on the contents.

How I get it to select the first empty row rather than having to ask it to
select a certain row as in the code below? Once selected I want to delete
all rows from there to the end.

Thanks

Sub DELROWS()
'
Rows("2:2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="="
Rows("9:9").Select
Range("B9").Activate
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.delete Shift:=xlUp
Selection.AutoFilter Field:=4
Rows("2:2").Select
Selection.AutoFilter
Range("B1").Select
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Simple - Del empties

nice Rick - I should have thought of that!



"Rick Rothstein" wrote:

Does this line of code do what you want?

Range("E4:E" & Rows.Count).SpecialCells(xlCellTypeBlanks).EntireR ow.Delete

--
Rick (MVP - Excel)


"LiAD" wrote in message
...
Hi,

I would like a code to delete empty rows based on column E (row 4 of the
table).

Using the recorded I apply a filter, use the filter to show the blank
cells
from col E. At this point I dont know how to ask VB to select the first
row
in table - it could be any row from 1 to 66500 depending on the contents.

How I get it to select the first empty row rather than having to ask it to
select a certain row as in the code below? Once selected I want to delete
all rows from there to the end.

Thanks

Sub DELROWS()
'
Rows("2:2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="="
Rows("9:9").Select
Range("B9").Activate
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.delete Shift:=xlUp
Selection.AutoFilter Field:=4
Rows("2:2").Select
Selection.AutoFilter
Range("B1").Select
End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Simple - Del empties

change
if cells(rw,"E")="" then
to
if cells(rw,"E").Interior.Colorindex = ???? then

to delete rows where cells are shaded ???

??? is a LONG number

"Patrick Molloy" wrote:

for rw = range("E65000").Exd(xlup).Row to 4 step -1
if cells(rw,"E")="" then
rows(rw),delete
end if
next

"LiAD" wrote:

Hi,

I would like a code to delete empty rows based on column E (row 4 of the
table).

Using the recorded I apply a filter, use the filter to show the blank cells
from col E. At this point I dont know how to ask VB to select the first row
in table - it could be any row from 1 to 66500 depending on the contents.

How I get it to select the first empty row rather than having to ask it to
select a certain row as in the code below? Once selected I want to delete
all rows from there to the end.

Thanks

Sub DELROWS()
'
Rows("2:2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="="
Rows("9:9").Select
Range("B9").Activate
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.delete Shift:=xlUp
Selection.AutoFilter Field:=4
Rows("2:2").Select
Selection.AutoFilter
Range("B1").Select
End Sub

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
VBA empties clipboard jeffbert Excel Programming 3 June 17th 08 01:58 AM
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Office Clipboard empties itself when enabling/disabling commandbars [email protected] Excel Programming 0 October 24th 07 06:39 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
Make it more simple or intuitive to do simple things Vernie Charts and Charting in Excel 1 March 16th 05 04:01 AM


All times are GMT +1. The time now is 11:51 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"