Public Function Zellbereich(Optional Hilfszelle As Variant) As Variant
Dim x As Variant
Zellbereich = "test"
If IsMissing(Hilfszelle) Then
Exit Function
Else
Hilfszelle = "test"
End If
End Function
Public Function Zellbereich(Optional Hilfszelle As Variant) As Variant
Dim x As Variant
'Zellbereich = "test"
If IsMissing(Hilfszelle) Then
Zellbereich = "test1"
Exit Function
Else
Zellbereich = "test2"
End If
End Function
Dann musst du mir noch erläutern, was du mit isMissing bezwecken willst?
Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.FormulaLocal, 13) = "=Zellbereich(" Then
Pos1 = InStr(Target.FormulaLocal, "(")
Pos2 = InStr(Target.FormulaLocal, ";")
Pos3 = InStr(Target.FormulaLocal, ")")
If Pos2 = 0 Then
'Ohne Hilfe - Hier nix machen
Else
PosWZelle = Mid(Target.FormulaLocal, Pos1 + 1, Pos2 - Pos1 - 1)
PosHZelle = Mid(Target.FormulaLocal, Pos2 + 1, Pos3 - Pos2 - 1)
Wert = Range(PosWZelle)
Range(PosHZelle) = Wert & " * (3 + 3) / 7"
'Mit Hilfe
End If
Else
End If
End Sub
2. Code für die UDF (im allg. Modul)
Public Function Zellbereich(ByVal Wertebereich As Range, Optional Hilfszelle As Range) As _
Variant
Dim Wert As Double
If Wertebereich Is Nothing Then
Exit Function
Else
Wert = Wertebereich * (3 + 3) / 7
End If
Zellbereich = Wert
End Function
Die Formelhilfe muss dann entsprechend der Formel immer angepasst werden.
Public Function Zellbereich(Optional Hilfszelle As Variant) As Variant
Dim x As Variant
Zellbereich = "test"
If IsMissing(Hilfszelle) Then
Exit Function
Else
Hilfszelle = "test"
End If
End Function
Public Function Zellbereich(Optional Hilfszelle As Variant) As Variant
Dim x As Variant
'Zellbereich = "test"
If IsMissing(Hilfszelle) Then
Zellbereich = "test1"
Exit Function
Else
Zellbereich = "test2"
End If
End Function
Dann musst du mir noch erläutern, was du mit isMissing bezwecken willst?
Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.FormulaLocal, 13) = "=Zellbereich(" Then
Pos1 = InStr(Target.FormulaLocal, "(")
Pos2 = InStr(Target.FormulaLocal, ";")
Pos3 = InStr(Target.FormulaLocal, ")")
If Pos2 = 0 Then
'Ohne Hilfe - Hier nix machen
Else
PosWZelle = Mid(Target.FormulaLocal, Pos1 + 1, Pos2 - Pos1 - 1)
PosHZelle = Mid(Target.FormulaLocal, Pos2 + 1, Pos3 - Pos2 - 1)
Wert = Range(PosWZelle)
Range(PosHZelle) = Wert & " * (3 + 3) / 7"
'Mit Hilfe
End If
Else
End If
End Sub
2. Code für die UDF (im allg. Modul)
Public Function Zellbereich(ByVal Wertebereich As Range, Optional Hilfszelle As Range) As _
Variant
Dim Wert As Double
If Wertebereich Is Nothing Then
Exit Function
Else
Wert = Wertebereich * (3 + 3) / 7
End If
Zellbereich = Wert
End Function
Die Formelhilfe muss dann entsprechend der Formel immer angepasst werden.