Private Sub UserForm_Initialize()
With Sheets("Valeurs")
TextVille = .Range("A1")
TextDate = .Range("A2") etc...
End With
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
With Sheets("Valeurs")
.Range("A1") = TextVille
.Range("A2") = TexDate etc...
End With
Private Sub UserForm_Initialize()
Dim CT As Control
Dim i&
'---
For Each CT In Me.Controls
If TypeName(CT) = "TextBox" Then
CT.Value = CT.Tag
End If
Next CT
End Sub
Private Sub UserForm_Terminate()
Dim CT As Control
Dim i&
'---
UsfName = Me.Name
For Each CT In Me.Controls
If TypeName(CT) = "TextBox" Then
i& = i& + 1
ReDim Preserve CollectionTextBox(1 To i&)
CollectionTextBox(i&).Name = CT.Name
CollectionTextBox(i&).Value = CT.Value
End If
Next CT
'---
Application.OnTime Now + TimeValue("00:00:00"), "SetValueInTag"
End Sub
Type structTextBox
Name As String
Value As String
End Type
Public CollectionTextBox() As structTextBox
Public UsfName As String
Sub SetValueInTag(Optional dummy As Byte)
Dim i&
Dim USFDesign As Object
'---
Set USFDesign = ThisWorkbook.VBProject.VBComponents(UsfName).Designer
For i& = 1 To UBound(CollectionTextBox)
USFDesign.Controls(CollectionTextBox(i&).Name).Tag = CollectionTextBox(i&).Value
Next i&
Erase CollectionTextBox
End Sub