Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Ctrl-Alt-Shift-F9

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Ctrl-Alt-Shift-F9

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" wrote in message
...
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
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
F9, Shift+F9, Ctrl+Alt+F9 etc john1978 Excel Discussion (Misc queries) 3 August 20th 09 10:35 AM
Ctrl+Shift+Down in a macro - doesn't re-run Astello[_2_] Excel Programming 3 October 16th 06 08:17 PM
Formula For CTRL+SHIFT+; donscarwash Excel Programming 1 June 11th 05 01:32 PM
CTRL+SHIFT+END RichardG Excel Programming 3 October 7th 04 04:58 PM
What does CTRL-ALT-SHIFT-F4 do? R Avery Excel Programming 7 June 2nd 04 01:57 PM


All times are GMT +1. The time now is 05:32 AM.

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

About Us

"It's about Microsoft Excel"