Excel Format textbox identique à cellule Source
Résolu
elglouton
Messages postés
197
Statut
Membre
-
elglouton Messages postés 197 Statut Membre -
elglouton Messages postés 197 Statut Membre -
Bonjour,
J'ai créer des Userform pour lequel je remplis des TextBox avec des données présent dans une feuille de calcul excel.
Existe il une façon de récupérer le format de cette cellule (différent en fonction des Cellules) afin de le représenter dans le textBox.
Est il aussi possible de faire apparaitre des textbox d'un userform en fonction des données présente dans un RowSource.
Si le RowSource est vide, je n'affiche pas mon textbox.
Si mon RowSource est plein j'affiche mon Textbox.
Connection (STILMAS ; <No PLC>)
TypeES (BD;I;O;M;T;C)
Type de données (WORLD;INT;DWORLD;DINT;REAL;TIMER;COUNTER)
Format (T;BIN;HEX;DEC;C)
En espérant avoir été clair je vous remerci par avance
J'ai créer des Userform pour lequel je remplis des TextBox avec des données présent dans une feuille de calcul excel.
Existe il une façon de récupérer le format de cette cellule (différent en fonction des Cellules) afin de le représenter dans le textBox.
Est il aussi possible de faire apparaitre des textbox d'un userform en fonction des données présente dans un RowSource.
Si le RowSource est vide, je n'affiche pas mon textbox.
Si mon RowSource est plein j'affiche mon Textbox.
"
"
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long _
, lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub CommandButtonMain_Click()
Unload Me
UserFormPushButton.Show
End Sub
Private Sub ImageSiemens_Click()
Me.PrintForm
End Sub
Private Sub CommandButtonMaison_Click()
Unload Me
UserFormMainMenu.Show
End Sub
''''''Pour fermer par Double Click, peux être supprimer''''''
Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Unload Me
End Sub
''''''Pour permettre le déplacement du userform, peux être supprimer''''''
Private Sub UserForm_MouseDown(ByVal Button As Integer _
, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ReleaseCapture
SendMessage FindWindow(vbNullString, Me.Caption), &HA1, 2, 0&
End Sub
Private Sub UserForm_Initialize()
Dim hWnd As Long, Style As Long
hWnd = FindWindow(vbNullString, Me.Caption)
Style = GetWindowLong(hWnd, -16) And Not &HC00000
SetWindowLong hWnd, -16, Style
DrawMenuBar hWnd
'Avoir le meme format dans CommandButtonHaut1_1 que dans ParametresFR!B165
If IsEmpty(Sheets("ParametresFR").Range("B165")) Then
CommandButtonHaut1_1.Visible = False
Else
UserFormForce1.CommandButtonHaut1_1.Caption = Sheets("ParametresFR").Range("B165").Value
End If
If IsEmpty(Sheets("ParametresFR").Range("C165")) Then
CommandButtonHaut1_2.Visible = False
Else
UserFormForce1.CommandButtonHaut1_2.Caption = Sheets("ParametresFR").Range("C165").Value
End If
If IsEmpty(Sheets("ParametresFR").Range("D165")) Then
CommandButtonHaut1_3.Visible = False
Else
UserFormForce1.CommandButtonHaut1_3.Caption = Sheets("ParametresFR").Range("D165").Value
End If
If IsEmpty(Sheets("ParametresFR").Range("E165")) Then
CommandButtonHaut1_4.Visible = False
Else
UserFormForce1.CommandButtonHaut1_4.Caption = Sheets("ParametresFR").Range("E165").Value
End If
If IsEmpty(Sheets("ParametresFR").Range("F165")) Then
CommandButtonHaut1_5.Visible = False
Else
UserFormForce1.CommandButtonHaut1_5.Caption = Sheets("ParametresFR").Range("F165").Value
End If
If IsEmpty(Sheets("ParametresFR").Range("G165")) Then
CommandButtonHaut1_6.Visible = False
Else
UserFormForce1.CommandButtonHaut1_6.Caption = Sheets("ParametresFR").Range("G165").Value
End If
If IsEmpty(Sheets("ParametresFR").Range("H165")) Then
CommandButtonHaut1_7.Visible = False
Else
UserFormForce1.CommandButtonHaut1_7.Caption = Sheets("ParametresFR").Range("H165").Value
End If
If IsEmpty(Sheets("ParametresFR").Range("I165")) Then
CommandButtonHaut1_8.Visible = False
Else
UserFormForce1.CommandButtonHaut1_8.Caption = Sheets("ParametresFR").Range("I165").Value
End If
If IsEmpty(Sheets("ParametresFR").Range("J165")) Then
CommandButtonHaut1_9.Visible = False
Else
UserFormForce1.CommandButtonHaut1_9.Caption = Sheets("ParametresFR").Range("J165").Value
End If
ComboBoxCentre1_1.RowSource = ("Connection")
ComboBoxCentre1_2.RowSource = ("TypeES")
ComboBoxCentre1_3.RowSource = ("Nombre")
ComboBoxCentre1_4.RowSource = ("Nombre")
ComboBoxCentre1_5.RowSource = ("Nombre")
ComboBoxCentre1_6.RowSource = ("Type_de_données")
ComboBoxCentre1_7.RowSource = ("Format")
ComboBoxCentre1_8.RowSource = ("Nombre")
ComboBoxCentre1_9.RowSource = ("Nombre")
'RowSource à afficher si RowSource1_1 est plein
ComboBoxCentre2_1.RowSource = ("Connection")
ComboBoxCentre2_2.RowSource = ("TypeES")
ComboBoxCentre2_3.RowSource = ("Nombre")
ComboBoxCentre2_4.RowSource = ("Nombre")
ComboBoxCentre2_5.RowSource = ("Nombre")
ComboBoxCentre2_6.RowSource = ("Type_de_données")
ComboBoxCentre2_7.RowSource = ("Format")
ComboBoxCentre2_8.RowSource = ("Nombre")
ComboBoxCentre2_9.RowSource = ("Nombre")
'RowSource à afficher si RowSource2_1 est plein
ComboBoxCentre3_1.RowSource = ("Connection")
ComboBoxCentre3_2.RowSource = ("TypeES")
ComboBoxCentre3_3.RowSource = ("Nombre")
ComboBoxCentre3_4.RowSource = ("Nombre")
ComboBoxCentre3_5.RowSource = ("Nombre")
ComboBoxCentre3_6.RowSource = ("Type_de_données")
ComboBoxCentre3_7.RowSource = ("Format")
ComboBoxCentre3_8.RowSource = ("Nombre")
ComboBoxCentre3_9.RowSource = ("Nombre")
End Sub"
Connection (STILMAS ; <No PLC>)
TypeES (BD;I;O;M;T;C)
Type de données (WORLD;INT;DWORLD;DINT;REAL;TIMER;COUNTER)
Format (T;BIN;HEX;DEC;C)
En espérant avoir été clair je vous remerci par avance
2 réponses
-
Bonjour,
J'ai créer des Userform pour lequel je remplis des TextBox Ce ne sont pas des TextBox mais des Combobox.
Si j'ai compris ce que vous voulez:
'Exemple pour ComboBoxCentre1_1.RowSource 'RowSource à afficher si RowSource1_1 est plein If ComboBoxCentre1_1.RowSource <> "" Then ComboBoxCentre2_1.RowSource = ("Connection") ComboBoxCentre2_2.RowSource = ("TypeES") ComboBoxCentre2_3.RowSource = ("Nombre") ComboBoxCentre2_4.RowSource = ("Nombre") ComboBoxCentre2_5.RowSource = ("Nombre") ComboBoxCentre2_6.RowSource = ("Type_de_données") ComboBoxCentre2_7.RowSource = ("Format") ComboBoxCentre2_8.RowSource = ("Nombre") ComboBoxCentre2_9.RowSource = ("Nombre") ComboBoxCentre2_1.Visible = True ComboBoxCentre2_2.Visible = True ComboBoxCentre2_3.Visible = True ComboBoxCentre2_4.Visible = True ComboBoxCentre2_5.Visible = True ComboBoxCentre2_6.Visible = True ComboBoxCentre2_7.Visible = True ComboBoxCentre2_8.Visible = True ComboBoxCentre2_9.Visible = True Else ComboBoxCentre2_1.Visible = False ComboBoxCentre2_2.Visible = False ComboBoxCentre2_3.Visible = False ComboBoxCentre2_4.Visible = False ComboBoxCentre2_5.Visible = False ComboBoxCentre2_6.Visible = False ComboBoxCentre2_7.Visible = False ComboBoxCentre2_8.Visible = False ComboBoxCentre2_9.Visible = False End If
A+-
-
-
-
-
Re,
Exemple de formatage info cellules excel dans Combobox UserForm
Private Sub ComboBox1_Change() 'format date: jj/mm/aaaa ComboBox1 = CDate(ComboBox1) End Sub Private Sub ComboBox2_Change() 'Format nombre: 12.12 (attention:arrondi!!!) ComboBox2 = Format(ComboBox2, "00.00") 'Format nombre: 12.12 sans arrondi ComboBox2 = Format(ComboBox2, "##.##") End Sub
Bonne suite
-
-
Bonjour,
C'est sympa un userform sans bouton de fermeture...
Est il donc possible de faire que le userform voit le contenu des cellules dans le format des cellules excel.
textbox1 = Format([Feuil1!A1].Value, [Feuil1!A1].NumberFormat)
eric
Jamais tu ne répondras à un mp non sollicité...
Bon, ça c'est fait.