Hi everyone,
I need your help, please. I need a macro that deletes all rows in which the value of the cells from columns A to D are <1.
The values are starting from A10 to D10.
For Example:
A B C D
10 1 2,5 3 0
11 0 0 0 0
12 5 0 0 0
The macro should delete row 11 because there are all values <1.
The idea is to check first if there are only numbers typed into the inputbox. This works. But I have problems to delete the rows if the number is =< in rows A to D. There happens nothing.
Can you help me please?
Thanks a lot.
Kind regards
Roman
Hi Marc,
If you start the macro, you get the inputbox. There you have to type in a number. The macro looks if it is a number. If not, then the macro can be stopped or you can try to type in a number again.
If you have typed in a number, then it is stored in the variable "wert".
With this number, the macro searches on sheet "Import" if the number "wert" is smaller or equal in the cells A-D in each row. If the number in a row, column A-D (in all Columns of this row), is equal or smaller then the varible "wert", then the row has to be deletet.
Sub Demo1() Dim V V = InputBox(vbLf & vbLf & "Valeur plancher :", " Suppression de lignes") If Not IsNumeric(V) Then Exit Sub Application.ScreenUpdating = False With ImportData.UsedRange.Resize(, 5).Rows .Columns(5).Formula = Replace("=AND(A1<=#,B1<=#,C1<=#,D1<=#)", "#", V) .Sort .Cells(5), xlAscending, Header:=xlNo V = Application.Match(True, .Columns(5), 0) If IsNumeric(V) Then .Item(V & ":" & .Count).Clear .Columns(5).Clear End With Application.ScreenUpdating = True End Sub
Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
The code can be so small just thinking how Excel can help instead of a poor full VBA way
as using a loop can be the slowest way, as clearing a block at once - even manually ! - is faster than deleting row by row …
Bookmarks