Monday 15 September 2014

excel - Find a row with specific text and delete this and the rest 4 rows below it -


I want to delete a specific cell area in 1000 files.

The location of this cell area is not the same in every file, it starts from A12 and in some others it starts with A20, A21 etc.

There are 5 lines in one column (rows) and I want to delete them all.

Therefore, I need it:

01) Find cell (first line) with specific text ("VVVV").

02) Select this cell and delete the remaining 4 (bottom)

03), select SHIFT CELLS

First of all, I can only select this Was the first line and the removal of it (the shells also change together). Here is my code that now removes the other rows, but there is a problem:

  sub deleteRows () '' deleterows macro '' keyboard shortcut: Ctrl + s' slow startrange string diameter andrange As string cell Find (what: = "VVVV"). StartRange = ActiveCell.AddressEndRange = ActiveCell.Address & amp; 4 ActiveSheet.Range (StartRange & amp; ":" & EndRange) Select the selection. Shift: = xlUp ending sub  

This removes more rows than expected, that means there may be a problem with the "andrange" value, I have to try to find such a function Which selects the category and removes it, for example, if the cell is in "A1: B1", then I want to select "A1: B1" as "A5: B5".

please try it:

  delete sub deleterows () '' Macro '' keyboard shortcut: Ctrl + s' slow startrange string as the string cell in the form of endand Select StartRange = ActiveCell.Address Selection.Offset (4, 0). Select EndRange = ActiveCell.Address ActiveSheet.Range (StartRange & amp; ":" and EndRange). Select the selection. Delete Shift: = xlUp closing sub  

No comments:

Post a Comment