MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Need help w/creating macro to delete rows

  Asked By: Jaymz    Date: Oct 20    Category: MS Office    Views: 861

I went through some of the past posts to
see if maybe my question may have been answered in the past. But I
didn't find anything or I didn't search very well.

I export data from our agency manager to Excel 2003 on a weekly
basis. I have 5 macros that help me get the report to a finished
product for my office. But I am wondering if there is a way that I
can create a macro or add to an existing macro that would delete rows
in the report that do not meet specific criteria.

Example: The report from our agency manager runs a production report
that includes all branches. My brokers are assigned rev_org 200
through 299. So I would like to create a macro that would delete all
rev_org (column header) that do not fall within 200-299.

I can create macros with the record macro with no problem. I am not
very knowledgeable in creating macros using VB. Any assistance on
this would greatly be appreciated.



1 Answer Found

Answer #1    Answered By: Adalwine Fischer     Answered On: Oct 20

When evaluating rows  to delete  I have found it best to work
from the bottom of the range up.

Copy, paste and modify the following into your Subroutine.

Dim i, c As Double
c = Range("A65536").End(xlUp).Row

For i = c To 1 Step -1
If Cells(i, x) > 299 or Cells(i, x) < 200 Then
Rows(i).Delete Shift:=xlUp
End If

*where x is the column number that rev_org can be found

Didn't find what you were looking for? Find more on Need help w/creating macro to delete rows Or get search suggestion and latest updates.