VBA: Change Chart Data Source (Useform)

Xlacs

Board Regular
Joined
Mar 31, 2021
Messages
105
Office Version
  1. 2016
Platform
  1. Windows
Hi Everyone!

I have this project that I am currently working on. So basically, what I wanted to achieve is to change the source data of a Bar Chart that is displayed in my userform.
I have attached a sample for reference.

***For example.

I have a auto populated textbox and the value of it depends on the current user of the system.
For my 2nd image, Adam is my example and in my userform, what I wanted to see is to filter the data for Adam, similar to my image 1.

And so on..

Any help would be appreciated.. Thank you in Advance.

Module Code:

VBA Code:
Sub ChangeChart(ChartName As String)

    Dim CurrentChart As Chart
    Dim FName As String
   
    FName = ThisWorkbook.Path & "\temp.gif"
   
    Set CurrentChart = ThisWorkbook.Sheets("Charts").ChartObjects(ChartName).Chart
   
    CurrentChart.Export Filename:=FName, filtername:="GIF"
   
    Staff.imgChart.Picture = LoadPicture(FName)


End Sub
 

Attachments

  • pic1.png
    pic1.png
    23.3 KB · Views: 5
  • pic2.png
    pic2.png
    139.9 KB · Views: 5

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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