I received this the other day and I thought I could work on it for them
would you please create a tutorial of a VBA that could delete rows that are not
desired and so this is what I've done so let me show you my sheet so what I've
done is I've did this is just data that I've downloaded from the internet and I
have customer numbers and then apparently some other things that go
along with it and I'm assuming that they would be looking to to find one that
they want to delete so I'm gonna kind of copy this one say let's say I want to
delete this one this row based on this number but what I'm gonna do first of
all is I'm gonna make this yellow so that you you'll be able to see which row
I'm deleting so now I've crashed my button which calling up my user form and
then we're gonna paste in the number that we've copied and with the one the
customer number in there we're gonna press the delete row and that now you
see that it is gone and now it's gone through the loop and it says that order
number is not found and so you say okay and so now I've got clear form and then
just X to close the form now let me show you the code so Visual Basic and then
I've done a user form and so this is user form one and so let's I've just
entered a field for the text and two buttons and let's look at the code for
the first button and it says account equals string last row equals string x
equals long last row equals sheet one range a one current regions row textbox
is the place where we're getting our account number message box if you don't
anter an account number it's going to say enter your account number here
account equals trim so if they put extra spaces in it it won't matter and then x
equals to do while sheets x1 so that is the second row first
column so that's a 2 it does not equal does not equal 0 or does not equal blank
now when I put this code in my description of my video I will have to
put in the words does not equal because I'm not allowed to put square brackets
in my description so getting past that we do a search for the range and the
range is looking for what the account number and it's looking through all the
search steps it's looking for formulas that whole search order searching the
direction next match case Falls that match format false and if the range is
nothing then message box no order number is found and so that's what what happens
when a you've deleted it it'll tell you coming back and tell you message block
that no order is found because it's being deleted ok else if it does find it
row number equals range road range row is the ranges that you found here rows
without the row that's on active cell entire row delete and then so we don't
have an extra extra space there what it does is shift up so it brings up the
bottom row to make the top row fit so there's not a blank there and then x
equals x plus 1 and then n diff and then we do the loop for the do-while and this
is ND that where we go to if that no order number was found and that goes to
the end so I will include this in in my description the the second piece of code
here I have for the second button and this button is my button that says clear
and it just says textbox 1 equals nothing now to display this on my sheet
I - for the button to work I have I've written this little piece of code and it
says sub button and use your form 1 equals start show and that just shows my
user form when I press the button so then when you put the button on your
screen you just assign it to this this macro so that's how you delete selected
rows from your data using VBA macro please subscribe