Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default Deleting rows with no value in column A

sub DeleteUnusedRows()
dim row as integer
row=1
while row<10000
if cells(a,1)="" then
rows(a).delete
end if
wend
end sub
' put attention in: while row<10000 the 10000 number is the maximum number
'of rows in your sheet. change it if you have a bigger number of rows


HTH

"scratching my head" wrote:

I have several spreadsheets in which 4 of every 5 Rows needs to be deleted.
ie: Row
1 is good, Row 6 is good, Row 11 is good, Row 16 is good, etc. I need to
delete Rows 2-5, 7-10, 12-15, etc. I would prefer to set a variable in the
macro to tell it how many sets of 4 consecutive rows I need deleted (with one
good row between each bad set of 4). The rows that need to be deleted are not
entirely blank, some of the cells have data (not needed) but there are a few
rows that are entirely blank. It needs to delete the rows irreguardless of
any data in that row. Help is appreciated as I am not a programmer but you
guys are really good.

OR

Every 5th cell in column A has data. I need to delete all ROWS that have no
data in COLUMN A(even if it is a "space" that was used to delete previous
data) in column A. How would it know when it reached the end of the data and
continue to delete the balance of the blank spreadsheet?

Thanks
Danny


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Deleting rows with no value in column A

When I attempt to run the code below, I get an error "if Cells(a,1)="" then"
that says there is a "application-defined or object-defined error".

What do I do?
Thanks for the help.
Danny

"filo666" wrote:

sub DeleteUnusedRows()
dim row as integer
row=1
while row<10000
if cells(a,1)="" then
rows(a).delete
end if
wend
end sub
' put attention in: while row<10000 the 10000 number is the maximum number
'of rows in your sheet. change it if you have a bigger number of rows


HTH

"scratching my head" wrote:

I have several spreadsheets in which 4 of every 5 Rows needs to be deleted.
ie: Row
1 is good, Row 6 is good, Row 11 is good, Row 16 is good, etc. I need to
delete Rows 2-5, 7-10, 12-15, etc. I would prefer to set a variable in the
macro to tell it how many sets of 4 consecutive rows I need deleted (with one
good row between each bad set of 4). The rows that need to be deleted are not
entirely blank, some of the cells have data (not needed) but there are a few
rows that are entirely blank. It needs to delete the rows irreguardless of
any data in that row. Help is appreciated as I am not a programmer but you
guys are really good.

OR

Every 5th cell in column A has data. I need to delete all ROWS that have no
data in COLUMN A(even if it is a "space" that was used to delete previous
data) in column A. How would it know when it reached the end of the data and
continue to delete the balance of the blank spreadsheet?

Thanks
Danny


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default Deleting rows with no value in column A

Sorry, copy this code

Sub DeleteUnusedRows()
Dim row As Integer
row = 1
While row < 1000
If Cells(row, 1) = "" Then
Rows(row).Delete
End If
row = row + 1
Wend
End Sub

Please tell me if it works fine¡¡¡

"scratching my head" wrote:

When I attempt to run the code below, I get an error "if Cells(a,1)="" then"
that says there is a "application-defined or object-defined error".

What do I do?
Thanks for the help.
Danny

"filo666" wrote:

sub DeleteUnusedRows()
dim row as integer
row=1
while row<10000
if cells(a,1)="" then
rows(a).delete
end if
wend
end sub
' put attention in: while row<10000 the 10000 number is the maximum number
'of rows in your sheet. change it if you have a bigger number of rows


HTH

"scratching my head" wrote:

I have several spreadsheets in which 4 of every 5 Rows needs to be deleted.
ie: Row
1 is good, Row 6 is good, Row 11 is good, Row 16 is good, etc. I need to
delete Rows 2-5, 7-10, 12-15, etc. I would prefer to set a variable in the
macro to tell it how many sets of 4 consecutive rows I need deleted (with one
good row between each bad set of 4). The rows that need to be deleted are not
entirely blank, some of the cells have data (not needed) but there are a few
rows that are entirely blank. It needs to delete the rows irreguardless of
any data in that row. Help is appreciated as I am not a programmer but you
guys are really good.

OR

Every 5th cell in column A has data. I need to delete all ROWS that have no
data in COLUMN A(even if it is a "space" that was used to delete previous
data) in column A. How would it know when it reached the end of the data and
continue to delete the balance of the blank spreadsheet?

Thanks
Danny


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
Deleting rows meeting certain criteria in a particular column tsraj Excel Discussion (Misc queries) 1 April 1st 10 07:58 PM
Deleting rows based on column values Dazed and Confused[_2_] New Users to Excel 3 February 6th 09 10:47 PM
deleting rows that is compared to a single column. treeroot Excel Discussion (Misc queries) 1 September 19th 08 07:21 PM
deleting entire rows with the same cell value in the first column Pedro F. Excel Discussion (Misc queries) 3 January 11th 06 07:10 PM
Deleting rows based upon the value in column D Sean Excel Programming 2 October 25th 04 08:59 PM


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