Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Delete Empty Cells in a Macro

1) In a range of cells (A1:B119) there are empty lines (e.g. A1:B1) which I
want to delete in a Macro. Is this possible?

2) When I sort a.m. range of cells (A1:B119), containing text, the empty
lines are on top, unless I sort descending. A way out of this other than
manually delete the emtpty cells? Hence question no. 1
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default Delete Empty Cells in a Macro



"fak119" wrote in message
...
1) In a range of cells (A1:B119) there are empty lines (e.g. A1:B1) which
I
want to delete in a Macro. Is this possible?



iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = iLastRow to 1
If Cells(i,"A").Value = "" And Cells(i,"B").Value = "" Then
Rows(i).delete
End If
Next i


2) When I sort a.m. range of cells (A1:B119), containing text, the empty
lines are on top, unless I sort descending. A way out of this other than
manually delete the emtpty cells? Hence question no. 1



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Delete Empty Cells in a Macro

Thank you, Bob, I´m sure this would help.

Unfortunately I am a very poor Macro programmer and I have never done one
like that before (loops, etc.)

Felix

"Bob Phillips" wrote:



"fak119" wrote in message
...
1) In a range of cells (A1:B119) there are empty lines (e.g. A1:B1) which
I
want to delete in a Macro. Is this possible?



iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = iLastRow to 1
If Cells(i,"A").Value = "" And Cells(i,"B").Value = "" Then
Rows(i).delete
End If
Next i


2) When I sort a.m. range of cells (A1:B119), containing text, the empty
lines are on top, unless I sort descending. A way out of this other than
manually delete the emtpty cells? Hence question no. 1




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default Delete Empty Cells in a Macro

Just wrap it in a macro.

First, select the sheet you want to work on. Then go to the VBIDE (Alt-F11),
insert a code module (InsertModule) and paste the code below

Sub ProcessData()
iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = iLastRow to 1
If Cells(i,"A").Value = "" And Cells(i,"B").Value = "" Then
Rows(i).delete
End If
Next i
End Sub

Go backto Excel (Alt-F11), get the list of macros (Alt-F8), select
Processdata from the list and hit the Run button.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"fak119" wrote in message
...
Thank you, Bob, I´m sure this would help.

Unfortunately I am a very poor Macro programmer and I have never done one
like that before (loops, etc.)

Felix

"Bob Phillips" wrote:



"fak119" wrote in message
...
1) In a range of cells (A1:B119) there are empty lines (e.g. A1:B1)
which
I
want to delete in a Macro. Is this possible?



iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = iLastRow to 1
If Cells(i,"A").Value = "" And Cells(i,"B").Value = "" Then
Rows(i).delete
End If
Next i


2) When I sort a.m. range of cells (A1:B119), containing text, the
empty
lines are on top, unless I sort descending. A way out of this other
than
manually delete the emtpty cells? Hence question no. 1






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 to delete a group of CELLS Excel Discussion (Misc queries) 4 May 8th 06 04:29 PM
Delete Row If Empty Macro Richard Excel Discussion (Misc queries) 3 January 20th 06 11:26 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Counting empty cells within a range of cells Rosehill - ExcelForums.com New Users to Excel 2 May 2nd 05 08:53 AM
Macro to copy value in empty cells Esrei Excel Discussion (Misc queries) 3 April 19th 05 03:54 PM


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