#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Blank lines

I need to be able to delete blank lines in a macro, and the only VBA code I
can find doesn't work if there's a formula in the cell, even if the value is
zero. I tried copying and pasting special (Values), but even though the
formula isn't there any more, it still won't delete that line. I would
appreciate any suggestions.

--
Message posted via http://www.officekb.com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Blank lines

Hi Frank

Do you check one column ?

Here is a example for the A column (row 1 -100)

Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 100
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "A").Value = "" Then .Rows(Lrow).Delete

End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Frank via OfficeKB.com" wrote in message ...
I need to be able to delete blank lines in a macro, and the only VBA code I
can find doesn't work if there's a formula in the cell, even if the value is
zero. I tried copying and pasting special (Values), but even though the
formula isn't there any more, it still won't delete that line. I would
appreciate any suggestions.

--
Message posted via http://www.officekb.com



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Blank lines

WOW! That was great! Thank you so very much. I have tried and tried to make
this work. I'd buy you lunch if you were here.

--
Message posted via http://www.officekb.com
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Blank lines


"Frank via OfficeKB.com" wrote in message
...
I need to be able to delete blank lines in a macro, and the only VBA code

I
can find doesn't work if there's a formula in the cell, even if the value

is
zero.


Why not? Paste your c ode.



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
Delete Blank Lines Templar Excel Discussion (Misc queries) 2 December 27th 08 05:08 PM
Macro not recognizing blank lines as blank pm Excel Discussion (Misc queries) 9 May 22nd 07 04:16 PM
blank lines at end S.E. Excel Programming 3 October 20th 04 04:08 PM
Blank lines David O'brien Excel Programming 2 February 24th 04 06:21 PM
how to automatically insert blank lines in between non-blank lines No Name Excel Programming 2 November 17th 03 03:40 PM


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