Supportnet Computer
Planet of Tech

Supportnet / Forum / Tabellenkalkulation

Wert aus Formel wird nicht in Userform in angezeigt.





Frage

Hallo zusammen, ich würde mich sehr freuen, wenn ich nochmals Eure Hilfe in Anspruch nehmen dürfte. Ich habe eine UserForm erstellt, die beim Doppelklick in eine Zelle den Datensatz anzeigen soll. Der Wert aus beiliegender Formel wir aber nicht angezeigt. Die Textbox bleibt leer. Die Formel lautet: [b]txtTextBox1.Text = Format(Evaluate("=" & txtTextBox2 & "+" & txtTextBox3 & "+0" & txtTextBox4), "0.00")[/b] Hat vielleicht jemand eine Idee, was damit nicht stimmt? Besten Dank vorab für die Unterstützung Gruß, meikel

Antwort 1 von Hajo_Zi

Hallo meikel,

Textboxen enthalten das was der Name sagt Text. Du verkettest Text und willst dem ein Format zuweisen ds geht nicht und außer dem hast Du zu beginn ein "="
Dein Code würde ergeben z. =123456799. Dem Ausdruck kannst u kein Format zuweisen.

Gruß Hajo

Antwort 2 von Meikel

Hi Hajo,

danke für die Info.

Was müßte ich denn machen, um einen berechneten Wert in der UserForm anzeigen zu können?

Hast Du vielleicht einen Tipp für mich.

Danke vorab und viele Grüße, meikel

Antwort 3 von Hajo_Zi

Halo Meikel,

txtTextBox1.Text = Format(Cdbl( txtTextBox2)+cdbl( txtTextBox3) + cdbl( txtTextBox4), "0.00")

ich hoffe mal ich habe keine Klammer vergessen.

Gruß Hajo

Antwort 4 von Meikel

Hallo Hajo,

passt, wunderbar !!!!

Hab' (leider) noch eine 2. Formel:

Basis wäre Deine Formel, s.u.

txtTextBox1.Text = Format(Cdbl( txtTextBox2)+cdbl( txtTextBox3) + cdbl( txtTextBox4), "0.00")

Nach TextBox4, das ganze, also (2+3+4)*TextBox5(%)+TextBox6

Könntest Du mir bitte diese Formel auch noch anpassen.

Es würde mich sehr freuen und wäre die Krönung meiner Applikation.

Tausend Dank vorab, Gruß meikel

Antwort 5 von Hajo_Zi

Hallo Meikel,

das ist doch nun einfache Formelarbeit

Format()Cdbl( txtTextBox2)+cdbl( txtTextBox3) + cdbl( txtTextBox4))*cdbl(Textbox5)/100+Cdbl(Textbox6), "0.00")

Ich gehe mal davon aus das für 10% 10 in der Textbox5 steht.

Gruß Hajo

Antwort 6 von Meikel

Hallo Hajo,

erstmal danke. Einfach Formelarbeit, hatte ich auch gedacht.

In Textbox5 steht der Wert als 5,0%


Hab' die Formel wie folgt eingefügt (funktioniert leider nicht)
txtTextBox1.Text = Format()CDbl(txtTextBox2 + CDbl(txtTextBox3) + CDbl(txtTextBox4)) * CDbl(txtTextBox5) / 100 + CDbl(txtTextBox6), "0.00")

Könntest Du das bitte nochmal überprüfen.

Danke vielmals vorab, Gruß meikel

Antwort 7 von Hajo_Zi

Hallo Meikel

Format()Cdbl( txtTextBox2)+cdbl( txtTextBox3) + cdbl( txtTextBox4))*cdbl(Mid(Textbox5,len(textbox5)-1))/100+Cdbl(Textbox6), "0.00")

Gruß Hajo

Antwort 8 von Meikel

Hallo Hajo,

klappt leider noch immer nicht.

Habe den Code so übernommen:
txtTextBox1.Text = Format((CDbl(txtTextBox2) + CDbl(txtTextBox3) + CDbl(txtTextBox4))* CDbl((Mid(txtTextBox5,Len(txtTextBox5)-1) / 100) + CDbl(txtTextBox6), "0.00")

Hab die Klammer nach Fornat von () in (( geändert, sonst wäre der Code rot. Es wird auch kein Fehler mehr angezeigt. Hab nochmal die Eigenschaften der Textbox kontrolliert, ist auch ok.

Wert wird einfach nicht angezeigt !

Hast Du noch eine Idee woran es liegen könnte ?

Gruß, meikel

Antwort 9 von Hajo_Zi

Hallo Meikel,

bei so komplizierten Problemen ist eine Beispieldatei nicht schlecht, dann braucht man es nicht nachbauen. Auf die Eigenschaft ".Rext" kann verzichtet werden.

Option Explicit

Sub Meikel()
Dim txtTextBox1 As String
Dim txtTextBox2 As String
Dim txtTextBox3 As String
Dim txtTextBox4 As String
Dim txtTextBox5 As String
Dim txtTextBox6 As String
txtTextBox2 = "13"
txtTextBox3 = "14"
txtTextBox4 = "15"
txtTextBox5 = "10%"
txtTextBox6 = "3"
txtTextBox1 = Format((CDbl(txtTextBox2) + CDbl(txtTextBox3) + CDbl(txtTextBox4)) * _
CDbl(Left(txtTextBox5, Len(txtTextBox5) - 1)) / 100 + CDbl(txtTextBox6), "0.00")
End Sub

Gruß Hajo

Antwort 10 von Meikel

Hallo Hajo,

wir sind fast da. Der Wert wird schon mal angezeigt. Aber irgendwie ist da noch einen Dreher drin:

TextBox1: 4,95
TextBox2: 0,12
TextBox3: 0,00
TextBox4: 0,15
TextBox5: 10%
TextBox6: 5,73 = Ergebnis (angezeigt wird nur die Differenz 0,66)

Bedeutet:

txtTextBox6= Format((CDbl(txtTextBox1) + CDbl(txtTextBox2) + CDbl(txtTextBox3)) * _
CDbl(Left(txtTextBox5, Len(txtTextBox5 - 1)) / 100 + CDbl(txtTextBox4), "0.00")

Sorry, das ich mich so blöd anstelle. Meine Konzentration ist leider nicht mehr auf dem Höhepunkt.

Was mach ich falsch??? Herzlichen Dank für Deine Hilfe.

Gruß, meikel

Antwort 11 von Meikel

Hallo Hajo,

ich hab's

Die 2. Formel enthält das Ergebnis der ersten Formel ohne die Prozentrechnung.
D.h. Ich hab das Ergebnis aus der ersten Formel (Antwort 3) der 2. Formel zugeordnet durch Addition hinzugefügt.

Jetzt passt es!!

Vielen herzlichen Dank für Deine Bemühungen und Geduld.
Auch diesmal konnte das Forum durch seine Experten wieder zum Erfolg beitragen.

Danke und schönen Abend, Gruß meikel