Variable non définie

Bonjour tout le monde. J'ai besoin d'aide s'il vous plaît j'ai un projet a rendre dans 3 jours je suis coincé

il s'agit d'une petite application utilisateur qui calculera la taille de la position (nombre d'actions) en fonction du risque que vous définissez (êtes prêt à prendre) par rapport à votre capital commercial.

J'ai un code, cependant j'ai un message d'erreur me disant " Erreur de compilation Variable non définie" en me soulignent

Voici le code vous trouverez ainsi mon fichier Merci d'avance :

Option Explicit

Private Sub cmdCalculate_Click()

Dim ws As Worksheet

Set ws = Sheet1

Dim c As Control

For Each c In Me.Frame1.Controls

If TypeName(c) = "TextBox" Then

If c = vbNullString Then

ShowErr c

Exit Sub

End If

End If

Next

ws.Range("D7").Value = Me.txtFunds

ws.Range("E7").Value = Me.txtPrice

ws.Range("F7").Value = Me.txtStop

ws.Range("G7").Value = Me.txtBroker

ws.Range("H7").Value = Me.txtRisk

Me.txtRisk2.Value = ws.Range("J7").Value

Me.txtUnits.Value = Format(ws.Range("I7").Value, "#,##0")

Me.txtParcel.Value = Format(ws.Range("K7").Value, "Currency")

End Sub

Private Sub ShowErr(c As Control)

MsgBox "Textbox " & c.Name & " cannot be empty!"

End Sub

Private Sub cmdClose_Click()

Unload Me

End Sub

Private Sub cmdReset_Click()

Unload Me

frmRisk.Show

End Sub

Private Sub Frame1_Click()

End Sub

Private Sub txtBroker_AfterUpdate()

Me.txtBroker = Format(Me.txtBroker, "Currency")

End Sub

Private Sub txtFunds_AfterUpdate()

Me.txtFunds = Format(Me.txtFunds, "Currency")

End Sub

Private Sub txtPrice_AfterUpdate()

Me.txtPrice = Format(Me.txtPrice, "Currency")

End Sub

Private Sub txtStop_AfterUpdate()

Me.txtStop = Format(Me.txtStop, "Currency")

End Sub

Private Sub UserForm_Click()

End Sub

Bonjour,

Si ton Excel est français, il faut écrire Set ws = Feuil1

ric

Merci beaucoup j'ai un autre souci avec excel

Il n'y a que 3 formules dans ce petit projet.

quand j'essaye de faire rentré les formules ça marche pas j'ai fait une capture d'écran d'un message d'erreur je vous laisse jeter un coup d’œil

2% des actions Cell I7

= IF (F7 = "", "", ((D7 * (H7 / 100)) - G7) / (E7-F7))

Risque $ Cellule J7

= IF (I7 = "", "", ((E7-F7) * I7) + G7)

Colis Prix Cell K7

= SI (I7 = "", "", (E7 * I7) + G7)

Salut Benalmeh,

Salut ric,

Mieux, tant qu'à faire...

Set ws = Worksheets("Feuil1")

Plus joli que de faire clignoter l'écran...

Private Sub cmdReset_Click()
'
Dim c As Control
'
For Each c In Me.Frame1.Controls
    If TypeName(c) = "TextBox" Then c.Text = ""
Next
'
End Sub

A+

Bonjour,

Un essai qui est agrémenté des suggestions de curulis57.

Formules incluses.

ric

Rechercher des sujets similaires à "variable definie"