Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1644to1648
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

CalculateFull für bestimmte Range

CalculateFull für bestimmte Range
25.09.2018 15:50:06
David
Hallo,
ich bin auf der Suche nach einer Möglichkeit Application.CalculateFull für gezielte Bereiche anzuwenden.
Der Hintergrund: In diesen Bereichen stehen UDFs in den Zellen, die dynamisch einen Bereich auswerten, der damit also nicht fest übergeben werden kann. Automatisches Aktualisieren funktioniert nicht, da ja nicht erkannt wird, dass die Zelle nicht weis, dass diese Änderung sie betrifft. Selbes gilt offenbar, für das einfache .Calculate . CalculateFull muss also zwingend verwendet werden, damit auch diese UDFs aktualisiert werden. Das Problem ist laut anderen Einträgen ja hinlänglich bekannt.
Warum CalculateFull nicht funktioniert: Die UDF geht eine Spalte durch und sucht die erste Zahl und dann die letzte, die Auswertung wird dann mit den dazwischen liegenden Zahlen gemacht. Diese Zahlen selbst stammen auch aus UDFs, welche allerdings feste Eingabeparamter haben, sich also auch automatisch aktualisieren.
Offensichtlich ist es so, dass CalculateFull diese innerhalb des abgesuchten Bereichs stehenden Zahlen noch nicht berechnet hat und die UDF sie deshalb nicht als Zahl erkennt und folglich in eine Schleife bis zum Blattende läuft. Denn wenn ich die UDF, händisch in die Zelle eintrage und Enter drücke, funktioniert es, da die auszuwertenden Zahlen ausgerechnet sind.
Hier mal die UDF:

Public Function rss_block(cl_mid_relativ As Double, Optional cl_high_or_low_relativ As Double =  _
_
3) As Double
'This function calculates the sum of uncertainties / deviations for the upper confidence level   _
_
within one block.
'(1 input paramter: mean relativ Confidence level, typically arround 50%), (2 input paramter:   _
_
high/low relativ Confidence level, typically arround 90%)
'Declaration of the variables; begin_area is the beginning of the summarized block,  _
end_area the end. Both are determined automatically.
Dim begin_area, end_area As Integer
Dim i, row, column As Integer
Dim sum_of_squares As Double
Dim sum_mid As Double
Dim sheet As String
begin_area = 1
sheet = Application.Caller.Parent.name
row = Application.Caller.row
column = Application.Caller.column
'All cells without a number as content are skipped and the first cell with a number is  _
defined as begin_area.
Do While IsNumeric(Worksheets(sheet).Cells(row + begin_area, column)) = False Or Worksheets( _
_
sheet).Cells(row + begin_area, column) = ""
MsgBox begin_area
begin_area = begin_area + 1
Loop
'Starting from begin_area, the last cell with a numeric value is searched downwards and  _
taken over as end_area.
'In addition, the square sum of the individual deviations of the lower confidence level  _
within the block is already formed (sum_of_squares).
end_area = begin_area
sum_of_squares = 0
sum_mid = 0
' Mid: 0,5 und ""
If cl_high_or_low_relativ = 3 Then
Do While IsNumeric(Worksheets(sheet).Cells(row + end_area, column)) And Worksheets( _
sheet).Cells(row + end_area, column)  ""
sum_mid = sum_mid + Worksheets(sheet).Cells(row + end_area, column)
end_area = end_area + 1
Loop
rss_block = sum_mid
Else
' UP: 0,5 und 0,1
If cl_mid_relativ > cl_high_or_low_relativ Then
Do While IsNumeric(Worksheets(sheet).Cells(row + end_area, column)) And Worksheets(  _
_
sheet).Cells(row + end_area, column)  ""
sum_mid = sum_mid + Worksheets(sheet).Cells(row + end_area, column - 1)
sum_of_squares = sum_of_squares + (Worksheets(sheet).Cells(row + end_area,  _
column - 1).Value - Worksheets(sheet).Cells(row + end_area, column).Value) ^ 2
end_area = end_area + 1
Loop
' Down: 0,5 und 0,9
ElseIf cl_mid_relativ  ""
sum_mid = sum_mid + Worksheets(sheet).Cells(row + end_area, column + 1)
sum_of_squares = sum_of_squares + (Worksheets(sheet).Cells(row + end_area,  _
column + 1).Value - Worksheets(sheet).Cells(row + end_area, column).Value) ^ 2
end_area = end_area + 1
Loop
End If
'The sum is formed. For this, the sum of the mean Cl is added to the root of the square  _
_
sum of the individual deviations of the lower Cl.
'Assuming that the lower CL is always relatively lower than the mean one, the sgn part   _
_
is superfluous, but is retained here as originally in the formula.
rss_block = sum_mid + Sgn(cl_mid_relativ - cl_high_or_low_relativ) * (sum_of_squares) ^  _
_
(1 / 2)
End If
End Function

Genauer, in dieser Schleife findet die UDF kein Ende:

'All cells without a number as content are skipped and the first cell with a number is  _
defined as begin_area.
Do While IsNumeric(Worksheets(sheet).Cells(row + begin_area, column)) = False Or Worksheets( _
_
sheet).Cells(row + begin_area, column) = ""
MsgBox begin_area
begin_area = begin_area + 1
Loop

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: CalculateFull für bestimmte Range
25.09.2018 15:51:06
David
Edit: Die MsgBox habe ich zur Kontrolle reingepackt, diese soll nicht zur eigentlichen UDF gehören.
AW: CalculateFull für bestimmte Range
25.09.2018 17:35:15
Luschi
Hallo David,
mache die Funktion 'volatil'

Public Function rss_block( ... ) As Double
Application.Volatile  'siehe Vba-Hilfe
End Function
Gruß von Luschi
aus klein-Paris
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige