Excel VBA: Sort, then Copy and Paste

前端 未结 2 1895
庸人自扰
庸人自扰 2021-01-22 05:26

All, I need to write a macro that does the following:

  1. On entry data into the last blank cell in column E, sort the entire worksheet by column E

2条回答
  •  [愿得一人]
    2021-01-22 06:25

    I'd suggest you to save the value that has been entered and search for this value after the sorting.

    Notice we may have dup data added into E column, so we'll need to store the other column's information as well until have a reliable key.

    So, once you know the value(s) you need to search, find the cell containing the data you added in the column E (that might be in any other row by now, not only in the last one) and use it as an anchor to your other operations.

    There are several ways to find a specific entry in a matrix (using Excel or pure VBA, as you wish). If you have problems implementing them, let us know.

    Having the cell address (in column E) that contains the value that has just been added, you'll use offset functions to set adjacent values. Again, if you have problems implementing it, let us know your doubt.

    Hope it helps :)

    Rgds

提交回复
热议问题