Hi, I am relatively new to VBA in excel and am having a hard time figuring out how to seach a column for a value and select and copy the range from the first to last match. And move that to column E.
For ex.
Column A B C D E F
Row
1 1 5 1
2 1 6 3
3 1 7
4 2 6
5 2 3
6 2 5
7 3 2
8 3 4
9 4 1
10
I want to search column A Range 1: until blank (in this case row 10). For the value in "D1". When it finds the first match i want to select that cell and each cell until the value no longer matches. (Column A will always be grouped together - all the 1's in line the 2's in line the 3's etc.)
So it would grab "1" the value in "D1" and it would select A1:A3.
Then Selection.End(xlToRight) so that A1:B3 is now selected. Cut that information and move it to cell E1.
Then repeat the process for "D2". (still searching column A until Row 10, even though rows 1, 2 and 3 are now blank) Pasting the information below the information that was pasted prior.
And continue until it reaches a blank in Column D.
The output would be
Column A B C D E F
Row
1 1 1 5
2 3 1 6
3 1 7
4 2 6 3 2
5 2 3 3 4
6 2 5
7
8
9 4 1
10
If there is a way to do this it would be greatly helpful. I have been able to make some things work but have been having a tough time. Thanks for the help
I attached two pictures of the examples above so it was readable.