VBA Dynamic Ranges

后端 未结 2 1662
北海茫月
北海茫月 2021-01-27 16:28

I wonder whether someone may be able to help me please.

I\'ve put together the code below which creates a new sheet in my workbook and applies dynamic named ranges and p

2条回答
  •  庸人自扰
    2021-01-27 16:44

    The best way is not to do it via code at all but use a dynamic named range which will change the range as you add new data.

    The named range formula below sets a dynamic named range covering range Sheet1!$A$4:$A$1000

    =OFFSET(Sheet1!$A$4,0,0,COUNTA(Sheet1!$A$4:$A$1000),1)
    
    1. Formulas/Name Manager
    2. New
    3. Enter Name, scope, and refers to formula above (comments are optional)
    4. OK

    enter image description here

    You could also use the whole column A:A but if you start counting from A4 then you need to adjust for the number of cells with value in A1:A3. In the picture example it would be

    =OFFSET(Sheet1!$A$4,0,0,COUNTA(Sheet1!$A:$A)-1,1)
    

提交回复
热议问题