PC Review


Reply
Thread Tools Rate Thread

Combo Boxes and Worksheet Events

 
 
=?Utf-8?B?UGhpbGlwIEogU21pdGg=?=
Guest
Posts: n/a
 
      29th Mar 2007
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 Pearson’s 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 With Quote
 
 
 
 
=?Utf-8?B?UGhpbGlwIEogU21pdGg=?=
Guest
Posts: n/a
 
      30th Mar 2007
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 Pearson’s 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box Values Not Sticking & Mult/ Combo Boxes in a WorkSheet questor Microsoft Excel Programming 1 15th Sep 2008 02:15 AM
Loop Through Combo Boxes on Worksheet and in Workbook AJ Master Microsoft Excel Programming 5 4th Jan 2008 09:28 AM
Best way to populate worksheet from 2 combo boxes jswasson Microsoft Excel Worksheet Functions 0 7th Jul 2006 01:21 PM
Not in List events for multiple combo boxes sike11 via AccessMonster.com Microsoft Access Forms 4 21st Jun 2006 02:31 PM
Using SUM with worksheet range selected by two combo boxes fifthhorseman Microsoft Excel Programming 1 18th Jun 2004 10:38 PM


Features
 

Advertising
 

Newsgroups
 


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