What area is covered by A2:A and A1 in accordance with this?
The code does not attempt to cover A2:A and A1 .
In this code:
Set items = Range("A2:A" & Range("A1").End(xlDown).Row)
Component "A2:A" & Range("A1").End(xlDown).Row combined as a single Range() parameter:
Thus, the whole part ends as "A2:A" & "4" or A2:A4 .
Given this, for your second screenshot, you can go with a similar process:
C5:C selects from C5 (which is the first βcellβ data cell);& concatenates the string;Range("C4") selects C4 (which is the "title" cell of the "Item" column);Range("C4").End(xlDown) is selected to the last non-empty cell in C starting with C4 ;Range("C4").End(xlDown).Row returns the number of the selected cell (in this case 7);
So, for the second screenshot you got:
Set items = Range("C5:C" & Range("C4").End(xlDown).Row)
source share