Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Combo Boxes and Worksheet Events

Hi.

I have a chart in a worksheet which changes according to selections made in
a user-form using combo-boxes. These combo boxes are from the forms toolbar
rather than the control toolbox.

I have derived the following code from the cited source and modified it as
noted. I have read Chip Pearsons notes on Events in Userform controls and
added the code €śFormEnableEvents = True€ť.

However it does not fully work until another activity updates the worksheet.
E.g. F2 and enter.

I could add a macro button with the instruction €śClick to update Chart€ť.
Can anyone indicate how I might amend the following code to make the update
happen automatically?

--------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'Base Code copied from
'http://peltiertech.com/Excel/Charts/AxisScaleLinkToSheet.html
' Category (X) Axis code removed as not required
' Chart name changed
' Cell References replaced by named ranges
'
'Need to ensure that events on userforms update the chart.
FormEnableEvents = True
'Identify the chart
With ActiveSheet.ChartObjects("Chart 5").Chart

' Set the characteristics for the Y Axis
With .Axes(xlValue)
..MajorUnit = ActiveSheet.Range("DScale").Value
..MinimumScale = ActiveSheet.Range("DMin").Value
..MaximumScale = ActiveSheet.Range("DMax").Value
End With

End With
End Sub
------------------

Further points.
1. The named ranges DScale, DMin, and D Max are updated by formulae.
2. The order of .MajorUnit, .MaximumScale, and .MinimumScale does not seem
to improve or impair performance.
3. The code is in the worksheet object code for the appropriate worksheet.
4. Workbook recalculation is set to automatic.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Combo Boxes and Worksheet Events

Bob Phillips suggested a change to Private Sub Worksheet_Calculate() and it
worked perfectly.

Thanks to all concerned.

Regards

Phil


"Philip J Smith" wrote:

Hi.

I have a chart in a worksheet which changes according to selections made in
a user-form using combo-boxes. These combo boxes are from the forms toolbar
rather than the control toolbox.

I have derived the following code from the cited source and modified it as
noted. I have read Chip Pearsons notes on Events in Userform controls and
added the code €śFormEnableEvents = True€ť.

However it does not fully work until another activity updates the worksheet.
E.g. F2 and enter.

I could add a macro button with the instruction €śClick to update Chart€ť.
Can anyone indicate how I might amend the following code to make the update
happen automatically?

--------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'Base Code copied from
'http://peltiertech.com/Excel/Charts/AxisScaleLinkToSheet.html
' Category (X) Axis code removed as not required
' Chart name changed
' Cell References replaced by named ranges
'
'Need to ensure that events on userforms update the chart.
FormEnableEvents = True
'Identify the chart
With ActiveSheet.ChartObjects("Chart 5").Chart

' Set the characteristics for the Y Axis
With .Axes(xlValue)
.MajorUnit = ActiveSheet.Range("DScale").Value
.MinimumScale = ActiveSheet.Range("DMin").Value
.MaximumScale = ActiveSheet.Range("DMax").Value
End With

End With
End Sub
------------------

Further points.
1. The named ranges DScale, DMin, and D Max are updated by formulae.
2. The order of .MajorUnit, .MaximumScale, and .MinimumScale does not seem
to improve or impair performance.
3. The code is in the worksheet object code for the appropriate worksheet.
4. Workbook recalculation is set to automatic.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Combo boxes to change options based on other Combo boxes. Ancient Wolf New Users to Excel 1 March 27th 09 06:29 PM
How to clear a group of combo boxes after a submit to another worksheet Jonah Excel Discussion (Misc queries) 1 March 7th 08 12:39 AM
Best way to populate worksheet from 2 combo boxes jswasson Excel Worksheet Functions 0 July 7th 06 01:21 PM
Combo Boxes built with Control Toolbox on a Worksheet Alan[_30_] Excel Programming 1 August 11th 05 11:28 AM
Using SUM with worksheet range selected by two combo boxes fifthhorseman Excel Programming 1 June 18th 04 10:38 PM


All times are GMT +1. The time now is 04:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"