LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to delete rows with text cells

Try this one but you need to specify the selected area by highlighting the
first to the end cell.

Sub DeleteEmptyCell()
Dim Rng As Range
For Each Rng In Selection
If Rng.Value = "" Then Rng.EntireRow.Delete
Next
End Sub



"zsalleh " ¼¶¼g©ó¶l¥ó
...
Hi all,

Can anyone help me with changing the vba code below to delete each row
with a text field in column c1:c10000? I am new to vba and just manage
to hack something up. However this code only deletes blank cells and
not cells with text.

Also is there a better way to specify the column range instead of doing
it by specifying the range like this...Set Rng =
ActiveSheet.Range("C1:C10000"). i.e. Is there a way to make it dynamic,
so regardless of how many rows there are, it will run through each and
every row with data in it. The problem that I faced is my data has the
occasionaly blank row between each row with data.

Anyway, enough said. Here is my code. Thanks in advance.

Sub DeleteText()
'
' Delete blank lines in column C
' Macro recorded 23/08/2004 by zsalleh
'

'
Windows("Workbook v2.xls").Activate
Sheets("Consolidation").Select
Application.ScreenUpdating = False
Dim Rng As Range
Set Rng = ActiveSheet.Range("C1:C10000")

For ix = Rng.Count To 1 Step -1
If Trim(Replace(Rng.Item(ix).Text, Chr(160), Chr(32))) = ""
Then
Rng.Item(ix).EntireRow.Delete
End If
Next
Application.ScreenUpdating = True

End Sub


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



 
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 to Delete the last N rows Colin Hayes Excel Discussion (Misc queries) 11 November 25th 11 12:35 AM
Macro to delete rows if... Sasikiran Excel Discussion (Misc queries) 6 June 29th 09 07:16 AM
Need macro to delete all text cells in an Excel range GVT Excel Worksheet Functions 2 February 26th 06 12:25 PM
delete empty rows between rows with text Paulo Baptista Excel Discussion (Misc queries) 2 February 28th 05 03:41 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM


All times are GMT +1. The time now is 02:00 AM.

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"