Подсчитайте непредсказуемое количество ячеек, а затем вставьте строки под заданными c строками в зависимости от результата подсчета - PullRequest
0 голосов
/ 05 августа 2020

Я пытаюсь создать код VBA, который обеспечивает следующее в следующей базе данных:

First stage

  1. I want to count the number of cells from G1 to the right until the cells are empty. In this case, I'd have 10 cells, from G1 to P1. The number of cells is unpredictable. I'm having problems with that since I'm new to VBA, and that isn't even the hard part.

  2. Then I want to divide the count by 2. And then insert as many rows under the rows 2,3,4,5... etc, aka under every row that is not empty as the value. In this case, since the count was 10, the code would insert five rows under row 2, five rows under row 3... It will always be an even number, that's not a problem.

  3. Then I'd have to copy and paste the values in G2 and H2 into E3 and F3. And then I'd insert the values from I2 and J2 into E4 and F4, and so on until that row is finished, then move onto row 2 (in the second picture it would be row 8). Maybe it would be better to count the number of used cells and insert rows accordingly row by row? Then the code would be easier, I wonder.

It would end up looking something like this, although in the "Final stage picture" I have only done the first row.

Thanks, I hope I was clear enough.

Последний этап

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...