VBA: Modify chart data range

后端 未结 4 1230
梦毁少年i
梦毁少年i 2020-11-30 11:54

My \"Chart data range\" is =\'sheet1\'!$A$1:$Z$10. I\'d like to make a VBA macro (or if anybody knows a formula I can use, but I couldn\'t figure one out) to in

4条回答
  •  孤街浪徒
    2020-11-30 12:29

    Offset function dynamic range makes it possible.

    Sample data

    enter image description here

    Steps

    • Define a dynamic named range =OFFSET(Sheet1!$A$2,,,1,COUNTA(Sheet1!$A$2:$Z$2)) and give it a name mobileRange
    • Right Click on Chart
    • Click on Select Data

    This screen will come

    enter image description here

    Click on Edit under Legend Entries.(mobiles is selected)

    enter image description here

    • change the Series value to point to mobileRange named range.
    • Now if data for future months are added to mobile sales it will automatically reflect in chart.

提交回复
热议问题