MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Delete row

  Asked By: Durril    Date: Nov 15    Category: MS Office    Views: 1828

I have a series of rows - 84 to 154 - which take their values from a series
of the same length above them - 8 to 77.

I'm attempting to write some code so that when I delete one row the
corresponding dependent row is also deleted.

I've used a macro to get the basics which are

Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=60
Selection.Delete Shift:=xlUp

I fiddled with this for some time before I realised it was always deleting
row 16, whatever I selected! (As I say I'm a complete beginner.)

I'd be grateful if someone could help me out with how to amend this so that
I can delete any row rather than simply rows 16 and 92. I've looked through
the online help assuming that there is some equivalent of ActiveCell but
can't find one.

Also, does it make a difference which of the rows I delete first? Should I
delete the dependent rows (the lower ones) or doesn't it matter.



2 Answers Found

Answer #1    Answered By: Madison Campbell     Answered On: Nov 15

This is not especially easy since as you delete  rows the two blocks
end up containing fewer and fewer rows, so the distance between the
two rows  can't be relied upon to determine which row  to delete in the
other series. Another way to match the two lines is needed.
Is one of the cells in each row unique to only those two rows to be
Will the series  always start at rows 8 and 77, both before and after
deletion? (I think the answer is no because in the code below you have
used SHift:=xlUp in both series.) Answer these and I'll come back.
Better still, send me a copy directly.

By the way, to delete the row you're on using macro code:


(Shift:=xlUP is not needed)
This will take out the entire row even if your selection is only one
cell, entire rows if your selection spans several rows.

(In your code below, the macro does the selecting, take the first line
out and the second line will delete the currently selected range.)

Answer #2    Answered By: Duane Walker     Answered On: Nov 15

and for offering to look at the

I will send you a copy directly as you suggest.

Didn't find what you were looking for? Find more on Delete row Or get search suggestion and latest updates.