ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Geeting error while setting datalabels through VBA (https://www.excelbanter.com/excel-programming/315746-geeting-error-while-setting-datalabels-through-vba.html)

Shilps[_2_]

Geeting error while setting datalabels through VBA
 
Hi,
I have this piece of code

ActiveSheet.ChartObjects("Chart 5").Activate
ab = ActiveChart.SeriesCollection(1).DataLabels.Count
Debug.Print "count", ab
lup = 10
With ActiveChart.SeriesCollection(1)
For a = 2 To ab
.DataLabels(a).Caption = Range("A" + CStr(lup)).Value
lup = lup + 1
Next
End With

It is giving RunTime error 1004 on line .DataLabels(a).Caption = Range("A"
+ CStr(lup)).Value

Whereas this code is running fine on all the other charts. Any clue why?

TIA




All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com