Looking for a Macro to erase particular rows in a given pattern

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a Macro to erase particular rows in a given pattern, but I can't find
one on the web. We are testing a new data collector and the raw data can be
opened in Excel. The problem is, we have 30000+ rows of data, but we only
need rows 1, 5, 9, 13, 17, 21 and so on... deleting every three rows manually
is taking forever.

I have to say I'm not used to the macros, but I think I can figure out how
to run one using the spreadsheet.

Can someone give me any suggetsions?
 
as long as you have at least one blank column to the right of your data
range, one quick way to do it is like this:

Enter the formula:

=IF(MOD(ROW(A1)-1,4)=0,0,1)

This formula will evaulate to 0 for all of the rows that you want to keep,
and to 1 for all of the rows that you want to delete.

Sort by that formula, delete all of the rows that have a 1 in that column.

I mean do all that in code, not suggesting manually. The only time this
approach would fail is if the furthest right column in the spreadsheet has
something already in it, so be aware of that.
 
The key is to work from bottom up. Try this idea

for i= cells(rows.count,"a").end(xlup).row to 2 step -3
rows(i).delete
next i
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top