Hi, I am hoping someone from this forum might have the answers I seek ...
Please check out this link:
Thanks.
Please check out this link:
Thanks.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub MyDataLabels()
For Each shp In ActiveSheet.Shapes
If shp.Type = msoTextBox Then
shp.Delete
End If
Next
With ActiveSheet.ChartObjects(1)
t1 = .Top
l1 = .Left
With .Chart
For Each pt In .SeriesCollection(1).Points
pt.HasDataLabel = True
With pt.DataLabel
.ShowCategoryName = True
t = .Text
Set ot = ActiveSheet.Shapes.AddLabel( _
msoTextOrientationHorizontal, _
.Left + l1, .Top + t1, 0#, 0#)
With ot
.TextFrame.AutoSize = msoTrue
.OLEFormat.Object.Text = t
End With
Set ot = Nothing
.Text = ""
End With
Next
End With
End With
End Sub
Function CreateChart()
Dim xlApp As Excel.Application
Dim xlWrkbk As Excel.Workbook
Dim xlChartObj As Excel.Chart
Dim xlSourceRange As Excel.Range
Dim xlColPoint As Excel.Point
Dim xlWrkSheet As Excel.Worksheet ' Excel Worksheet
Dim iRow As Integer ' Index variable for the current Row
Dim iCol As Integer ' Index variable for the current Row
Const cNumCols = 10 ' Number of points in each Series
Const cNumRows = 2 ' Number of Series
x = 1
On Error GoTo Err_CreateChart
ReDim aTemp(1 To cNumRows, 1 To cNumCols)
'Start Excel
' Create a Microsoft Excel object.
Set xlApp = CreateObject("Excel.Application")
' create a new workbook
Set xlWrkbk = xlApp.Workbooks.Add
Set xlWrkSheet = xlWrkbk.Worksheets(1)
' Create a new chart.
Set xlChartObj = xlApp.Charts.Add
' Insert data into Cells for the two Series:
For iRow = 1 To cNumRows
For iCol = 1 To cNumCols
aTemp(iRow, iCol) = x + iCol
Next iCol
x = x + 1
Next iRow
xlWrkSheet.Range("A1").Resize(cNumRows, cNumCols).Value = aTemp
' Format the chart.
With xlChartObj
' Specify chart type
.ChartType = xl3DBarClustered
' Set the source and range of the chart.
.SetSourceData Source:=xlWrkSheet.Range("A1").Resize(cNumRows, cNumCols)
' Create and set the title; set title font.
.HasTitle = True
With .ChartTitle
.Characters.Text = "My Chart Title"
.Font.Size = 18
End With
' Delete the label at the far left of the y-axis.
.Axes(xlCategory).Delete
.HasLegend = True
' format the series
With .SeriesCollection(1)
.Name = "My Series #1"
.Interior.Color = RGB(160, 120, 250)
For x = 1 To 10
With .Points(x)
.HasDataLabel = True
.DataLabel.Top = .DataLabel.Top + 1
.DataLabel.Left = 0
.DataLabel.Font.Size = 9
.DataLabel.Caption = "One" & " - " & "RATHER LONG" & " - " & "Label"
End With
Next x
MyDataLabels xlChartObj.SeriesCollection(1)
End With
With .SeriesCollection(2)
.Name = "My Series #2"
.Interior.Color = RGB(250, 250, 140)
For x = 1 To 10
With .Points(x)
.HasDataLabel = True
.DataLabel.Top = .DataLabel.Top + 1
.DataLabel.Left = 0
.DataLabel.Font.Size = 9
.DataLabel.Text = "Two" & " - " & "RATHER LONG" & " - " & "Label"
End With
Next x
MyDataLabels xlChartObj.SeriesCollection(2)
End With
'formatting the category axis
With .Axes(xlCategory)
.HasTitle = True
End With
With .Axes(xlValue)
.HasTitle = True
With .AxisTitle
.Caption = "How Many Boo-Boos"
'.Font.Size = 12
.Orientation = xlHorizontal
End With
End With
End With
xlApp.Visible = True
xlApp.UserControl = True
Exit_CreateChart:
Set xlChartObj = Nothing
Set xlWrkbk = Nothing
Set xlApp = Nothing
Exit Function
Err_CreateChart:
MsgBox CStr(Err) & " " & Err.Description
Resume Exit_CreateChart
End Function
Sub MyDataLabels(sc As Series)
With sc.Parent
t1 = 0
l1 = 0
For Each pt In sc.Points
pt.HasDataLabel = True
With pt.DataLabel
.ShowCategoryName = True
t = .Text
Set ot = sc.Parent.Parent.Shapes.AddLabel( _
msoTextOrientationHorizontal, _
.Left + l1, .Top + t1, 0#, 0#)
With ot
.TextFrame.AutoSize = msoTrue
.OLEFormat.Object.Text = t
End With
Set ot = Nothing
.Text = ""
End With
Next
End With
End Sub
Sub MyDataLabels(sc As Series)
With sc.Parent
t1 = .Parent.ChartArea.Top
l1 = .Parent.ChartArea.Left
t1 = 0
li = 0
i = 10
For Each pt In sc.Points
pt.HasDataLabel = True
With pt.DataLabel
.ShowCategoryName = True
t = .Text
[b][red] .Text = "X"[/red][/b]
Set ot = sc.Parent.Parent.Shapes.AddLabel( _
msoTextOrientationHorizontal, _
.Left + l1, .Top + t1, 0#, 0#)
With ot
.TextFrame.AutoSize = msoTrue
.OLEFormat.Object.Text = t & i
i = i + 10
End With
Set ot = Nothing
.Text = ""
End With
Next
End With
End Sub