Updating a dynamic range for a chart

VBAnewb2master

New Member
Joined
Aug 18, 2014
Messages
1
I am trying to have a excel chart that would be controled by a scollbar and combobox
I have an existing chart with dynamic ranges so for example dataSetA is defined as

Code:
<code style="margin: 0px; padding: 0px; border: 0px; font-size: 13.63636302947998px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">     =OFFSET([COLOR=#808080]'Starting Sheet'!$B$2,0,0,37,1)[/COLOR]</code>

and I reference this range in the chart with the following


Code:
<code style="margin: 0px; padding: 0px; border: 0px; font-size: 13.63636302947998px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">     =trans_test.xls!filmThickness</code>

so I have my scrollbar and combobox drawn and named and I am trying to fill out the vba for it. Since I have a named range I was just trying to edit that value with the following and hoping Excel would do the rest but it is not working. My code snip is below. I was hoping to just have the range updated and it would filter through to the chart.

Code:
<code style="margin: 0px; padding: 0px; border: 0px; font-size: 13.63636302947998px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">[COLOR=#00008B]Dim[/COLOR] timePosition [COLOR=#00008B]As[/COLOR] MSForms.ScrollBar
[COLOR=#00008B]Dim[/COLOR] dataSet [COLOR=#00008B]As[/COLOR] MSForms.ComboBox
[COLOR=#00008B]Set[/COLOR] timePosition = ActiveSheet.timeControl
[COLOR=#00008B]Set[/COLOR] dataSet = ActiveSheet.itemList
[COLOR=#00008B]Dim[/COLOR] datavalues [COLOR=#00008B]As[/COLOR] Range
[COLOR=#00008B]Set[/COLOR] datavalues = Range(Range([COLOR=#800000]"B1$1"[/COLOR]), Range([COLOR=#800000]"C22"[/COLOR]).Offset(timePosition.Value, [COLOR=#800000]0[/COLOR]).[COLOR=#00008B]End[/COLOR](xlT</code>oRight))

I want to be able to use the combobox to move from sheet to sheet and the scroll bar to move between datasets on that sheet. I just need a general idea how I can alter the offset formula that I used to first define the range. If I could update that I can make this work. Thanks in advance.
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,215,110
Messages
6,123,143
Members
449,098
Latest member
Doanvanhieu

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