![]() |
delete row with criteria (vba)
hi all,
i have 2 questions, i need a code that will delete some rows if there a "x" in column a. if there a "x" at a25 .. i want the macro to delete c25, f25 aa25 but i want the macro to be multirange like "x" in those cells a15,a16, a159 ,ect. a"z" where the macro will delete c"z", f"z", aa"z" next question. in the same order of idea, is it possible to highlight a range of row with the mouse and run the macro. so if u highlight row 5:10 the macro will delete c 5:10 f 5:10 aa:25. if it is possible that the macro run whatever the highligth is like a5:a10 or af5:af10 that will still run. ty |
delete row with criteria (vba)
wrote in message ups.com... hi all, i have 2 questions, i need a code that will delete some rows if there a "x" in column a. if there a "x" at a25 .. i want the macro to delete c25, f25 aa25 but i want the macro to be multirange like "x" in those cells a15,a16, a159 ,ect. a"z" where the macro will delete c"z", f"z", aa"z" For i = 1 To Cells(Rows.Count,"A").End(xlUp).Row If Cells(i,"A").Value = "x" Or cells(i, "A").Value = "z" Then Cells(i,"C").ClearContents Cells(i,"F").ClearContents Cells(i,"AA").ClearContents End If Next i next question. in the same order of idea, is it possible to highlight a range of row with the mouse and run the macro. so if u highlight row 5:10 the macro will delete c 5:10 f 5:10 aa:25. if it is possible that the macro run whatever the highligth is like a5:a10 or af5:af10 that will still run. For Each cell In Selection.Columns(1).Cells If cell.Value = "x" Or cell.Value = "z" Then cell.Offset(0,2).ClearContents cell.Offset(0,5).ClearContents cell.Offset(0,26).ClearContents End If Next i |
delete row with criteria (vba)
ty bob
Bob Phillips wrote: wrote in message ups.com... hi all, i have 2 questions, i need a code that will delete some rows if there a "x" in column a. if there a "x" at a25 .. i want the macro to delete c25, f25 aa25 but i want the macro to be multirange like "x" in those cells a15,a16, a159 ,ect. a"z" where the macro will delete c"z", f"z", aa"z" For i = 1 To Cells(Rows.Count,"A").End(xlUp).Row If Cells(i,"A").Value = "x" Or cells(i, "A").Value = "z" Then Cells(i,"C").ClearContents Cells(i,"F").ClearContents Cells(i,"AA").ClearContents End If Next i next question. in the same order of idea, is it possible to highlight a range of row with the mouse and run the macro. so if u highlight row 5:10 the macro will delete c 5:10 f 5:10 aa:25. if it is possible that the macro run whatever the highligth is like a5:a10 or af5:af10 that will still run. For Each cell In Selection.Columns(1).Cells If cell.Value = "x" Or cell.Value = "z" Then cell.Offset(0,2).ClearContents cell.Offset(0,5).ClearContents cell.Offset(0,26).ClearContents End If Next i |
All times are GMT +1. The time now is 10:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com