Bind chart data without selecting/activating

KillGorack

New Member
Joined
Jan 23, 2006
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Past practices here work of course, just would like the syntax for doing this without selecting stuff.

VBA Code:
    ' Good greif can we do this without selecting stuff??!
    ThisWorkbook.Sheets(sht).Select
    ActiveSheet.ChartObjects("trend_" & shp).Activate
    
    ' Nominal Line
    With ActiveChart.FullSeriesCollection(1)
        .Name = "=data!$C$" & dataLocation + 1
        .Values = "=data!$D$" & dataLocation + 1 & ":$" & DataWidthLetter & "$" & dataLocation + 1
        .XValues = "=data!$D$" & dataLocation + 6 & ":$" & DataWidthLetter & "$" & dataLocation + 6
        .Format.Line.Visible = msoTrue
        .Format.Line.Weight = 0.25
        .Format.Line.ForeColor.RGB = RGB(0, 0, 0)
    End With

Tried someting like... to no avail...

VBA Code:
  ' Nominal Line
  With ThisWorkbook.Sheets(sht).ChartObjects("trend_" & shp).FullSeriesCollection(1)
      .Name = "=data!$C$" & dataLocation + 1
      .Values = "=data!$D$" & dataLocation + 1 & ":$" & DataWidthLetter & "$" & dataLocation + 1
      .XValues = "=data!$D$" & dataLocation + 6 & ":$" & DataWidthLetter & "$" & dataLocation + 6
      .Format.Line.Visible = msoTrue
      .Format.Line.Weight = 0.25
      .Format.Line.ForeColor.RGB = RGB(0, 0, 0)
  End With
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try the following . . .

VBA Code:
With ThisWorkbook.Sheets(sht).ChartObjects("trend_" & shp).Chart.FullSeriesCollection(1)

Hope this helps!
 
Upvote 0
Try the following . . .

VBA Code:
With ThisWorkbook.Sheets(sht).ChartObjects("trend_" & shp).Chart.FullSeriesCollection(1)

Hope this helps!

Perfect yes. Thank you I also have to color bars one at a time. I will try to use the above to do that as well..
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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