Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default find and delete empty rows

I'm trying to create a code that will carry out the following.
Check for entries in column 'U' from cell 7 downover until there are no more
entries in column U (i say this so that it does not check all the way to the
bottom of the sheet and take forever, may be wrong though). Then for every
entry in column 'U', check to see if an entry exists in activecell.offset(0,
18). If no entry exists, delete that row.
I have managed to do this by finding the last row and checking if that is
empty and deletes if it is, but it only works once as I dont know how to loop
and it also only checks if the last row is empty.
Could any of you excel wizards help me out or point me in the right direction.
Thanks
Ian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default find and delete empty rows


LastRow = Range("U" & Rows.count).end(xlup).row
for RowCount = LastRow to 7 step - 1
if Range("R" & RowCount) = "" then
Row(RowCount).Delete
end if
next RowCount


"Woodi2" wrote:

I'm trying to create a code that will carry out the following.
Check for entries in column 'U' from cell 7 downover until there are no more
entries in column U (i say this so that it does not check all the way to the
bottom of the sheet and take forever, may be wrong though). Then for every
entry in column 'U', check to see if an entry exists in activecell.offset(0,
18). If no entry exists, delete that row.
I have managed to do this by finding the last row and checking if that is
empty and deletes if it is, but it only works once as I dont know how to loop
and it also only checks if the last row is empty.
Could any of you excel wizards help me out or point me in the right direction.
Thanks
Ian

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default find and delete empty rows

Thanks Joel.

I have tried it as follows

Sub TextBox883_Click()
'
' TextBox883_Click Macro
' Macro recorded 20/04/2009 by BPPassPort User
'
LastRow = Range("U" & Rows.Count).End(xlUp).Row
For RowCount = LastRow To 7 Step -1
If Range("R" & RowCount) = "" Then
Row(RowCount).Delete
End If
Next RowCount

'
End Sub

However I receive the following message
Compile Error:
Sub or function not defined
and it highlights the word Row, just before (RowCount).Delete


"joel" wrote:


LastRow = Range("U" & Rows.count).end(xlup).row
for RowCount = LastRow to 7 step - 1
if Range("R" & RowCount) = "" then
Row(RowCount).Delete
end if
next RowCount


"Woodi2" wrote:

I'm trying to create a code that will carry out the following.
Check for entries in column 'U' from cell 7 downover until there are no more
entries in column U (i say this so that it does not check all the way to the
bottom of the sheet and take forever, may be wrong though). Then for every
entry in column 'U', check to see if an entry exists in activecell.offset(0,
18). If no entry exists, delete that row.
I have managed to do this by finding the last row and checking if that is
empty and deletes if it is, but it only works once as I dont know how to loop
and it also only checks if the last row is empty.
Could any of you excel wizards help me out or point me in the right direction.
Thanks
Ian

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default find and delete empty rows

The code should be Rows with an s on the end.
Rows(RowCount).Delete

However, I am confused by the code against what you asked for. You said that
you wanted to test the value in Offset(0, 18). Did you mean offset 18 from
column U? If you did then that is column AM.

Joel's code tests column R which is the 18th column on the worksheet. (It is
not even Offset 18 from the first column. It is Offset 17 from the first
column.)

Anyway whatever column you want to test then replace "R" with that column Id.


--
Regards,

OssieMac


"Woodi2" wrote:

Thanks Joel.

I have tried it as follows

Sub TextBox883_Click()
'
' TextBox883_Click Macro
' Macro recorded 20/04/2009 by BPPassPort User
'
LastRow = Range("U" & Rows.Count).End(xlUp).Row
For RowCount = LastRow To 7 Step -1
If Range("R" & RowCount) = "" Then
Row(RowCount).Delete
End If
Next RowCount

'
End Sub

However I receive the following message
Compile Error:
Sub or function not defined
and it highlights the word Row, just before (RowCount).Delete


"joel" wrote:


LastRow = Range("U" & Rows.count).end(xlup).row
for RowCount = LastRow to 7 step - 1
if Range("R" & RowCount) = "" then
Row(RowCount).Delete
end if
next RowCount


"Woodi2" wrote:

I'm trying to create a code that will carry out the following.
Check for entries in column 'U' from cell 7 downover until there are no more
entries in column U (i say this so that it does not check all the way to the
bottom of the sheet and take forever, may be wrong though). Then for every
entry in column 'U', check to see if an entry exists in activecell.offset(0,
18). If no entry exists, delete that row.
I have managed to do this by finding the last row and checking if that is
empty and deletes if it is, but it only works once as I dont know how to loop
and it also only checks if the last row is empty.
Could any of you excel wizards help me out or point me in the right direction.
Thanks
Ian

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
Hpw do I delete multiple empty rows found between filled rows? Bill Excel Worksheet Functions 2 November 15th 09 07:12 PM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM
Delete Rows with Empty Cells with empty column 1 Scott Excel Programming 5 October 2nd 06 11:57 PM
how do i find and delete all empty rows in an excel worksheet AinSF Excel Worksheet Functions 3 September 1st 06 01:38 AM
Find last row of data and delete empty rows Pat Excel Programming 3 February 17th 05 12:34 AM


All times are GMT +1. The time now is 09:05 AM.

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"