VBA create dynamic graph from two columns

papakos

New Member
Joined
Apr 10, 2017
Messages
12
Here is my problem

I have a user form contains a ListBox that been populated from column A. It's ok fixed that.
I have 3 commandbuttons (TEMP, HUMIDITY,RAIN) and one PictureBox.
I'm trying to create a graph that contains x axis= Jan, Feb, Mar, Apr, May, Jun and y-axis the values from cells under TEMP etc
The graph will be displayed in PictureBox when i press one of the 3 commandButtons and will be depending from the selection of ListBox(ALASKA etc)

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD]TEMP[/TD]
[TD]HUMIDITY[/TD]
[TD]RAIN[/TD]
[/TR]
[TR]
[TD]ALASKA[/TD]
[TD]JAN[/TD]
[TD]-5[/TD]
[TD]95[/TD]
[TD]154[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]FEB[/TD]
[TD]-7[/TD]
[TD]92[/TD]
[TD]124[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]MAR[/TD]
[TD]1[/TD]
[TD]88[/TD]
[TD]88[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]APR[/TD]
[TD]5[/TD]
[TD]74[/TD]
[TD]54[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]MAY[/TD]
[TD]9[/TD]
[TD]65[/TD]
[TD]22[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]JUN[/TD]
[TD]18[/TD]
[TD]48[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ALABAMA[/TD]
[TD]JAN[/TD]
[TD]3[/TD]
[TD]45[/TD]
[TD]25[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]FEB[/TD]
[TD]7[/TD]
[TD]58[/TD]
[TD]38[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]MAR[/TD]
[TD]14[/TD]
[TD]55[/TD]
[TD]24[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]APR[/TD]
[TD]19[/TD]
[TD]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N[/TD]
[TD]31[/TD]
[TD]23[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
papakos, you haven't clearly stated your problem or asked a question. What have you tried and where are you running into difficulty?

You have a typo in your posted data: BOSTON has two JUNs.

Your data layout in post #1 may reflect your spreadsheet layout. While blank rows and empty cells sometimes make it easier for humans to read, that layout creates difficulties when we use a computer to sort and filter the data. Formulas and programs are much easier to write when a flat file data structure is used.

If you're having problems creating the dynamic chart, I've posted a non-VBA spreadsheet using your data at https://www.dropbox.com/s/256t23m52xgmo5b/2017-12-19_weather_dynamic_chart.xlsx?dl=0. I've used data validation dropdowns for the user to select the data to display.

I am sorry I can't help you transfer the chart to your VBA userform, but perhaps what I've shown in my spreadsheet will help you.
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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