Formeln auf einer UserForm in einer TextBox anzeigen. Z. B. "Formula", "FormulaLocal"... und wie muss die Formel in VBA eingegeben werden.
Show formulas on a UserForm in a TextBox. For example, "Formula", "FormulaLocal" ... and how to enter the formula in VBA.
Hier noch eine Beispieldatei / Here's a sample file:
Formeln auf einer UserForm in einer TextBox darstellen...[ZIP 20 KB]
Code gehört in eine UserForm (UserForm1) / Code belongs in a UserForm (UserForm1):
Code gehört in ein Modul (Modul2) / Code belongs in a module (Module2):
Code gehört in ein Modul (Modul1) / Code belongs in a module (Module1):
Code gehört in den Codebereich des Tabellenblattes / Code belongs in the code area of the worksheet:
Show formulas on a UserForm in a TextBox. For example, "Formula", "FormulaLocal" ... and how to enter the formula in VBA.
Hier noch eine Beispieldatei / Here's a sample file:
Formeln auf einer UserForm in einer TextBox darstellen...[ZIP 20 KB]
Code gehört in eine UserForm (UserForm1) / Code belongs in a UserForm (UserForm1):
OptionExplicit
'--------------------------------------------------------------------------
' Module : UserForm1
' Procedure : UserForm_Activate
' Author : Case (Ralf Stolzenburg)
' Date : 16.05.2018
' Purpose : Aktives Control in UserForm andere Farbe...
'--------------------------------------------------------------------------
PrivateSubUserForm_Activate()
DimlngTMPAsLong
CommandButton1.TabStop=False
WithActiveCell
If.HasFormulaThen
TextBox1.Text=.Formula
TextBox2.Text=.FormulaArray
TextBox3.Text=.FormulaHidden
TextBox4.Text=.FormulaLocal
TextBox5.Text=.FormulaR1C1
TextBox6.Text=.FormulaR1C1Local
TextBox7.Text=Replace(.Formula,"""","""""")
Else
ForlngTMP=1To6
Me.Controls("TextBox"&lngTMP).Text=""
NextlngTMP
EndIf
EndWith
CallStartTimer
AppActivateApplication.Caption
EndSub
PrivateSubUserForm_QueryClose(CancelAsInteger,CloseModeAsInteger)
IfCloseMode=0ThenCancel=True
CallStopTimer
EndSub
PrivateSubCommandButton1_Click()
UnloadMe
EndSub
Code gehört in ein Modul (Modul2) / Code belongs in a module (Module2):
OptionExplicit
OptionPrivateModule
PrivateDeclareFunctionKillTimerLib"user32.dll"_
(ByValhWndAsLong,ByValnIDEventAsLong)AsLong
PrivateDeclareFunctionSetTimerLib"user32.dll"_
(ByValhWndAsLong,ByValnIDEventAsLong,_
ByValuElapseAsLong,ByVallpTimerFuncAsLong)AsLong
PrivateDeclareFunctionFindWindowLib"user32.dll"_
Alias"FindWindowA"(ByVallpClassNameAsString,_
ByVallpWindowNameAsString)AsLong
PrivateConstEXUSERFORM="ThunderDFrame"
PrivatehWndAsLong
'--------------------------------------------------------------------------
' Module : Modul2
' Procedure : StartTimer
' Author : Case (Ralf Stolzenburg)
' Date : 16.05.2018
' Purpose : Aktives Control in UserForm andere Farbe - API - Timer...
'--------------------------------------------------------------------------
PublicSubStartTimer()
hWnd=FindWindow(EXUSERFORM,UserForm1.Caption)
SetTimerhWnd,0&,100&,AddressOfControlTimer
EndSub
SubStopTimer()
KillTimerhWnd,0&
EndSub
PrivateSubControlTimer(ByValhWndAsLong,ByValnIDEventAsLong,_
ByValuElapseAsLong,ByVallpTimerFuncAsLong)
OnErrorResumeNext
DimobjControlAsControl
ForEachobjControlInUserForm1.Controls
IfTypeName(objControl)<>"CommandButton"Then
objControl.BackColor=&H80000005
ElseIfTypeName(objControl)<>"TextBox"Then
UserForm1.ActiveControl.BackColor=&H80FF80
Else
UserForm1.ActiveControl.BackColor=&H80000005
EndIf
NextobjControl
EndSub
Code gehört in ein Modul (Modul1) / Code belongs in a module (Module1):
OptionExplicit
SubMain()
UserForm1.Show0
EndSub
Code gehört in den Codebereich des Tabellenblattes / Code belongs in the code area of the worksheet:
OptionExplicit
PrivateSubWorksheet_SelectionChange(ByValTargetAsRange)
DimlngTMPAsLong
IfNotTarget.CountLarge>1Then
WithTarget
If.HasFormulaThen
UserForm1.TextBox1.Text=.Formula
UserForm1.TextBox2.Text=.FormulaArray
UserForm1.TextBox3.Text=.FormulaHidden
UserForm1.TextBox4.Text=.FormulaLocal
UserForm1.TextBox5.Text=.FormulaR1C1
UserForm1.TextBox6.Text=.FormulaR1C1Local
UserForm1.TextBox7.Text=Replace(.Formula,"""","""""")
Else
ForlngTMP=1To6
UserForm1.Controls("TextBox"&lngTMP).Text=""
NextlngTMP
EndIf
EndWith
EndIf
EndSub