View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Sam via OfficeKB.com Sam via OfficeKB.com is offline
external usenet poster
 
Posts: 247
Default VBA Code to Find & AutoFilter last zero occurrence

Hi Patrick,

Thanks for taking the time to reply - much appreciated.

My VBA knowledge is very, very limited. Not sure how to get your code working
based on my original example code.
What should the variables you use be declared as etc.?
Will I have to manually select the data before running the code?
Will the autofilter still be done within the macro?

Patrick Molloy wrote:
so you only want to see the rows where the last zero in each column occurs?

Yes
I think to do this you your loop per column should start at the last row,
its quicker as the first zero it find will be the last

Yes, Great!

for rw= lastrow to 2 step -1
if cells(rw,cl)=0 then
'blah
exit for
end if
next


you need to place a value, say "X" in another column
so in my loop blah would be
cells(rw,"A") =- "X"


after running this loop through all columns
for cl = 11 to 17 'starting at k (11)
for rw= lastrow to 2 step -1
if cells(rw,cl)=0 then
cells(rw,10)="X" 'place x in column J

Don't understand - place any value? cells(rw,10)="X" 'place x in column J

exit for
end if
next ' next row if zero not found yet
next ' do the next column


now just autofilter for X in column J

How will the autofilter be done within macro?

Further assistance would be most appreciated.

Cheers,
Sam

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