#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro

Does anyone have some ideas on how to do this? I'm trying to write a macro
that will look at cell A1(which will be an Number) and then look over 3
columns to the right and if it says lets say PAID then delete row and move to
cell A2 if it doesn't say PAID then move to next row and repeat the process...
any ideas??

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro

sub deleterows()
Dim lastrow as Long, i as Long
lastrow = cells(rows.count,1).End(xlup).row
for i = lastrow to 1 step -1
if lcase(cells(i,"D").value) = "paid" then
rows(i).delete
end if
Next
End Sub

It is best to work from the bottom up or you could miss values.

I interpret 3 rows over as being column D, if it is another column, change
the letter "D" to reflect that column.

There are other ways to do this using the Find method, but this is direct
and easy to understand.

--
Regards,
Tom Ogilvy

"Newbee via OfficeKB.com" wrote:

Does anyone have some ideas on how to do this? I'm trying to write a macro
that will look at cell A1(which will be an Number) and then look over 3
columns to the right and if it says lets say PAID then delete row and move to
cell A2 if it doesn't say PAID then move to next row and repeat the process...
any ideas??

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro

The easiest way may be to use datafilterautofilter and delete all at once.
Record a macr
OR

for each c in range("a2:a200")
if ucase(c.offset(,3))="PAID" then c.entirerow.delete
next c

--
Don Guillett
SalesAid Software

"Newbee via OfficeKB.com" <u27679@uwe wrote in message
news:6eef63c0b143a@uwe...
Does anyone have some ideas on how to do this? I'm trying to write a macro
that will look at cell A1(which will be an Number) and then look over 3
columns to the right and if it says lets say PAID then delete row and move
to
cell A2 if it doesn't say PAID then move to next row and repeat the
process...
any ideas??

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro

for the code example Don provided, if you have two rows containing PAID, one
will be skipped. this is the reason I said loop backwards.

--
Regards,
Tom Ogilvy


"Don Guillett" wrote:

The easiest way may be to use datafilterautofilter and delete all at once.
Record a macr
OR

for each c in range("a2:a200")
if ucase(c.offset(,3))="PAID" then c.entirerow.delete
next c

--
Don Guillett
SalesAid Software

"Newbee via OfficeKB.com" <u27679@uwe wrote in message
news:6eef63c0b143a@uwe...
Does anyone have some ideas on how to do this? I'm trying to write a macro
that will look at cell A1(which will be an Number) and then look over 3
columns to the right and if it says lets say PAID then delete row and move
to
cell A2 if it doesn't say PAID then move to next row and repeat the
process...
any ideas??

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




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 recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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