Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to delete rows that show no value but contain formulas

Hello,

I am trying to find a macro that will delete rows that show no value o
text but have formulas in them. Can anybody help?

Thank you,
Lilian

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default how to delete rows that show no value but contain formulas

Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, "A").Value= "" and _
Cells(row_index, "A").hasformula then
Rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub


-----Original Message-----
Hello,

I am trying to find a macro that will delete rows that

show no value or
text but have formulas in them. Can anybody help?

Thank you,
Liliana


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to delete rows that show no value but contain formulas

Thank you very much, Frank. It works!!!!

It takes few minutes to run so I am wondering if there's a way t
specify a range (let's say 5000 rows), maybe it will work faster.

Also, is there an easy way for the macro to autoexecute when openin
the file? (it's a shared file so it may be opened by other user)

Thank you,
Lilian

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default how to delete rows that show no value but contain formulas

Hi
this macro only processes the used range. So specifying a range won't
help. If you want to autoexecute it one way would be to rename the
macro to
Auto_Open()


--
Regards
Frank Kabel
Frankfurt, Germany


Thank you very much, Frank. It works!!!!

It takes few minutes to run so I am wondering if there's a way to
specify a range (let's say 5000 rows), maybe it will work faster.

Also, is there an easy way for the macro to autoexecute when opening
the file? (it's a shared file so it may be opened by other user)

Thank you,
Liliana


---
Message posted from http://www.ExcelForum.com/


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to delete rows that show no value but contain formulas

Thanks again. Works perfectly.

Lilian

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default how to delete rows that show no value but contain formulas

Hi Liliana,

If you used the macro as Auto_Open you would have to identify the
workshee that this was to be applied to and probably create problems
for future mainenance.

You can really speed it up if you turn off calculation during the
macro -- and turn it back on afterwards.
http://www.mvps.org/dmcritchie/excel/slowresp.htm

But that still took a long time, so with some additional changes
1 instead fo "A" and the use of WITH

Sub delete_rows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For row_index = lastrow To 1 Step -1
With Cells(row_index, 1)
If .HasFormula + (Trim(.Value) = "") Then .EntireRow.Delete
End With
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Frank Kabel" wrote in message ...
Hi
this macro only processes the used range. So specifying a range won't
help. If you want to autoexecute it one way would be to rename the
macro to
Auto_Open()


--
Regards
Frank Kabel
Frankfurt, Germany


Thank you very much, Frank. It works!!!!

It takes few minutes to run so I am wondering if there's a way to
specify a range (let's say 5000 rows), maybe it will work faster.

Also, is there an easy way for the macro to autoexecute when opening
the file? (it's a shared file so it may be opened by other user)

Thank you,
Liliana


---
Message posted from http://www.ExcelForum.com/





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
Complex sheets - how can I delete rows without destroying formulas? Sybille Lausitz Links and Linking in Excel 1 June 6th 08 08:47 AM
Delete a row without dirupting the formulas in the following rows Soulscream Excel Worksheet Functions 2 January 16th 08 06:28 PM
Code to delete rows and column cells that have formulas in. GarToms Excel Worksheet Functions 1 January 18th 06 01:04 PM
How to delete rows using formulas Rere Excel Worksheet Functions 1 December 28th 05 08:28 PM
with formulas that show negative results I want to show zero inste brit64 Excel Discussion (Misc queries) 6 August 29th 05 11:12 PM


All times are GMT +1. The time now is 03:50 PM.

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

About Us

"It's about Microsoft Excel"