VBA: add data label from cell value

samahiji

Board Regular
Joined
Oct 6, 2015
Messages
82
Office Version
  1. 2019
Platform
  1. Windows
Hello

Excel 2013 offers adding data label from cell value. i want to add data label for series collections, but the below code failed!!

please help.

Code:
                     With .SeriesCollection.NewSeries
                    .Name = "=" & COM.Name & "!R10C3"
                    .Values = "=" & COM.Name & "!R" & 11 & "C2:R" & COM.Cells(1, 1).Value & "C2"
                    .XValues = "=" & COM.Name & "!R" & 11 & "C1:R" & COM.Cells(1, 1).Value & "C1"
                      .Border.Color = RGB(0, 102, 204)
                      .Format.Line.Weight = 0.1
                    
With .FullSeriesCollection
                    .ApplyDataLabels
                    .ShowRange = True
                    .showvalues = False
                    .DataLabels.Format.TextFrame2.TextRange.InsertChartField msoChartFieldRange, _
                    "=" & COM.Name & "!R" & 11 & "C" & (Currcol + 1) & ":R" & COM.Cells(1, 1) & "C" & (Currcol + 1), 0
                   End With
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,214,788
Messages
6,121,600
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top