PC Review


Reply
Thread Tools Rate Thread

Ctrl-Alt-Shift-F9

 
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      4th Sep 2007
I have written a custom function in Excel which works fine:

Function Sum_Dollars(Cell_Ref)
For Col_Count = 8 To 256
If Cells(5, Col_Count) = <test_val> Then Sum_Dollars = Sum_Dollars + 1
Next Col_Count
End Function

This re-calculates based on a drop down list which hides and unhides a
series of Columns in a workbook:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If OldValC1 = "" Then OldValC1 = Me.Range("C1")

If Me.Range("C1").Value <> OldValC1 Then
Cells.Select
Selection.EntireColumn.Hidden = False
If Me.Range("C1").Value = "Show All" Then
OldValC1 = Me.Range("C1").Value
Range("C1").Select
Exit Sub
End If
For Col_Count = 8 To 256
If IsEmpty(Cells(6, Col_Count)) Then Exit For

Application.EnableEvents = False
If Cells(6, Col_Count) = "$" And Cells(5, Col_Count) <>
Me.Range("C1") Then
Columns(Col_Count).Select
Selection.EntireColumn.Hidden = True
End If
Application.EnableEvents = True
Next
OldValC1 = Me.Range("C1").Value
Range("C1").Select
End If

End Sub

Problem is that my Function does not re-calculate when I change the drop
down box value. I have tried application.volatile in the function, but this
stops the "Worksheet Change" macro from working. I have tried all the
".Calculate" variations I can think of. The only thing that seems to work is
pressing "Ctrl-Alt-Shift-F9". Is there a way to program this command in VBA?
Or is there another solution to my problem?

Rich


 
Reply With Quote
 
 
 
 
Charles Williams
Guest
Posts: n/a
 
      4th Sep 2007
Excel only recalculates functions when at least one of the function
arguments change: so you need to make sure that all of the cells referenced
by the function appear in the range arguments for the function.

for more information about UDFs see
http://www.DecisionModels.com/calcsecretsj.htm

Charles
______________________
Decision Models
FastExcel 2.3 now available
Name Manager 4.0 now available
www.DecisionModels.com

"Rich" <(E-Mail Removed)> wrote in message
news:0B4E7501-9865-4BCE-A2EA-(E-Mail Removed)...
>I have written a custom function in Excel which works fine:
>
> Function Sum_Dollars(Cell_Ref)
> For Col_Count = 8 To 256
> If Cells(5, Col_Count) = <test_val> Then Sum_Dollars = Sum_Dollars + 1
> Next Col_Count
> End Function
>
> This re-calculates based on a drop down list which hides and unhides a
> series of Columns in a workbook:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Application.ScreenUpdating = False
> If OldValC1 = "" Then OldValC1 = Me.Range("C1")
>
> If Me.Range("C1").Value <> OldValC1 Then
> Cells.Select
> Selection.EntireColumn.Hidden = False
> If Me.Range("C1").Value = "Show All" Then
> OldValC1 = Me.Range("C1").Value
> Range("C1").Select
> Exit Sub
> End If
> For Col_Count = 8 To 256
> If IsEmpty(Cells(6, Col_Count)) Then Exit For
>
> Application.EnableEvents = False
> If Cells(6, Col_Count) = "$" And Cells(5, Col_Count) <>
> Me.Range("C1") Then
> Columns(Col_Count).Select
> Selection.EntireColumn.Hidden = True
> End If
> Application.EnableEvents = True
> Next
> OldValC1 = Me.Range("C1").Value
> Range("C1").Select
> End If
>
> End Sub
>
> Problem is that my Function does not re-calculate when I change the drop
> down box value. I have tried application.volatile in the function, but
> this
> stops the "Worksheet Change" macro from working. I have tried all the
> ".Calculate" variations I can think of. The only thing that seems to work
> is
> pressing "Ctrl-Alt-Shift-F9". Is there a way to program this command in
> VBA?
> Or is there another solution to my problem?
>
> Rich
>
>



 
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
Ctrl-Alt-Delete / Ctrl-Shift-Esc--------Task Manager James Welch Windows Vista General Discussion 0 20th Sep 2006 02:38 AM
Ctrl+Shift+5 shortcut is displayed as Ctrl+Shift+D5 Jonas Bergman Microsoft Dot NET Framework Forms 1 17th May 2006 03:03 PM
Other keys besides CTRL+SHIFT, ALT+SHIFT to switch input languages? Yevgeniy Makarov Windows XP Help 2 5th Apr 2006 04:10 AM
Keys besides Ctrl+Shift, Alt+Shift for switching imput languages? Yevgeniy Makarov Windows XP General 0 4th Apr 2006 02:24 AM
Old VB Shift-F2 / Ctrl-Shift-F2 Finally solved in VS.NET 2003 Chris Mullins Microsoft Dot NET 2 11th Aug 2003 10:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:52 AM.