Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default create macro that erases rows having blank cells and

let's say i have this:

column O

row 1 750
row 2 0
row 3 blank cell
row 4 ----------
etc

how can i create a macro that looks column O, delete rows that contain 0
values, blank cells, and ---------.

thanks for your help

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 301
Default create macro that erases rows having blank cells and

Try this:
Sub DeleteRows()
n=Activesheet.Usedrange.Rows.Count
For i=n to 1 step -1
if cells(i,15).value="----------" or cells(i,15).value=0 or
isblank(cells(i,15)) then rows(i).delete
Next
End Sub

Bob Umlas
Excel MVP

"andresg1975" wrote in message
...
let's say i have this:

column O

row 1 750
row 2 0
row 3 blank cell
row 4 ----------
etc

how can i create a macro that looks column O, delete rows that contain 0
values, blank cells, and ---------.

thanks for your help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default create macro that erases rows having blank cells and

it didn't work compile error


"Bob Umlas" wrote:

Try this:
Sub DeleteRows()
n=Activesheet.Usedrange.Rows.Count
For i=n to 1 step -1
if cells(i,15).value="----------" or cells(i,15).value=0 or
isblank(cells(i,15)) then rows(i).delete
Next
End Sub

Bob Umlas
Excel MVP

"andresg1975" wrote in message
...
let's say i have this:

column O

row 1 750
row 2 0
row 3 blank cell
row 4 ----------
etc

how can i create a macro that looks column O, delete rows that contain 0
values, blank cells, and ---------.

thanks for your help




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default create macro that erases rows having blank cells and

here is a revision that changes Isblank to Isempty and uses itty bitty lines
so you don't have word wrap problems. compiled for me:

Sub DeleteRows()
n = ActiveSheet.UsedRange.Rows.Count
For i = n To 1 Step -1
If Cells(i, 15).Value = _
"----------" Or Cells(i, 15) _
.Value = 0 Or IsEmpty( _
Cells(i, 15)) Then _
Rows(i).Delete
Next
End Sub

--
Regards,
Tom Ogilvy


"andresg1975" wrote:

it didn't work compile error


"Bob Umlas" wrote:

Try this:
Sub DeleteRows()
n=Activesheet.Usedrange.Rows.Count
For i=n to 1 step -1
if cells(i,15).value="----------" or cells(i,15).value=0 or
isblank(cells(i,15)) then rows(i).delete
Next
End Sub

Bob Umlas
Excel MVP

"andresg1975" wrote in message
...
let's say i have this:

column O

row 1 750
row 2 0
row 3 blank cell
row 4 ----------
etc

how can i create a macro that looks column O, delete rows that contain 0
values, blank cells, and ---------.

thanks for your help




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default create macro that erases rows having blank cells and

I'm not sure how the perfomance compares to previous solutions but this
seems to work.

Sub DeleteColumnOBlankCells()
Columns("O:O").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
End sub

Dave Parker

andresg1975 wrote:
let's say i have this:

column O

row 1 750
row 2 0
row 3 blank cell
row 4 ----------
etc

how can i create a macro that looks column O, delete rows that contain 0
values, blank cells, and ---------.

thanks for your help




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default create macro that erases rows having blank cells and

Sorry I didn't read closely enough - I see now that you also wanted to
delete zeroes.

Dave

wrote:
I'm not sure how the perfomance compares to previous solutions but this
seems to work.

Sub DeleteColumnOBlankCells()
Columns("O:O").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
End sub

Dave Parker

andresg1975 wrote:
let's say i have this:

column O

row 1 750
row 2 0
row 3 blank cell
row 4 ----------
etc

how can i create a macro that looks column O, delete rows that contain 0
values, blank cells, and ---------.

thanks for your help


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default create macro that erases rows having blank cells and

I have used your "delete rows" code in my application and it works perfectly.
I just have a question - how does the macro finds the last member of the
list? I'm assuming it has something to do with the
ActiveSheet.UsedRange.Rows.Count statement. At first I thought "UsedRange"
must be a named range, but its not.


"Tom Ogilvy" wrote:

here is a revision that changes Isblank to Isempty and uses itty bitty lines
so you don't have word wrap problems. compiled for me:

Sub DeleteRows()
n = ActiveSheet.UsedRange.Rows.Count
For i = n To 1 Step -1
If Cells(i, 15).Value = _
"----------" Or Cells(i, 15) _
.Value = 0 Or IsEmpty( _
Cells(i, 15)) Then _
Rows(i).Delete
Next
End Sub

--
Regards,
Tom Ogilvy


"andresg1975" wrote:

it didn't work compile error


"Bob Umlas" wrote:

Try this:
Sub DeleteRows()
n=Activesheet.Usedrange.Rows.Count
For i=n to 1 step -1
if cells(i,15).value="----------" or cells(i,15).value=0 or
isblank(cells(i,15)) then rows(i).delete
Next
End Sub

Bob Umlas
Excel MVP

"andresg1975" wrote in message
...
let's say i have this:

column O

row 1 750
row 2 0
row 3 blank cell
row 4 ----------
etc

how can i create a macro that looks column O, delete rows that contain 0
values, blank cells, and ---------.

thanks for your help




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
MACRO HELP - deleting rows containing a range of blank cells DavidHawes Excel Discussion (Misc queries) 9 February 26th 07 03:40 PM
How do I create a Macro to sort data and insert blank rows & subto karinmpfa Excel Worksheet Functions 2 April 25th 06 09:57 PM
create blank rows Coal Miner Excel Programming 5 April 20th 06 05:36 PM
Create macro to paste rows of text cells to lower end of other row RodFerd Excel Programming 3 January 20th 06 05:31 AM
Can I create a macro to identify and delete blank rows in a range? carlsondj Excel Programming 6 June 10th 05 12:38 AM


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