Link to home
Start Free TrialLog in
Avatar of vlahomt
vlahomt

asked on

Help with vb macro in excel to check a column in active row and delete the row.

I need a macro that will check the cell in the avctive row in a specific column agains a cell on another sheet and then if it does not fit the criteria then delete the row.  here is what I have right now.

Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Sheets.Add
    ActiveSheet.Paste
     Range("A2").Select
      Do Until IsEmpty(ActiveCell)
        if
          activerow(b)<= activesheet.sheet1 range("g1")
        then
          Selection.EntireRow.Delete
        ActiveCell.Offset(1, 0).Select

I have never coded in vb before so I know at least part of my problem is syntax and key words thanks for your help.
ASKER CERTIFIED SOLUTION
Avatar of patrickab
patrickab
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vlahomt
vlahomt

ASKER

Patrick,

Can I change the scenerio a little bit.
what if I want to test multiple cells on sheet1 and if each cell meets the condition copy the eniter row to a new sheet.

so if cell A1>10 and cell C1<2 and cell F1>0 then copy row 1 to sheet 2 row 1.

then move down a row on sheet 2 to allow for the next row to copy over.
vlahomt,

That is a totally different question to the one you started with. Perhaps you'd like to post another question for that.

Patrick
Forced accept.

Computer101
EE Admin