Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dim currentTopPos As Double
Private Sub cmdSaveData_Click()
Dim settings As Variant
Dim info() As String
Dim index As Long
With Sheets(SHEET_SETTINGS)
ReDim info(1 To getLR(.Name, "A") - 1)
settings = .Range("A2:D" & getLR(.Name, "A")).Value
For index = LBound(settings, 1) To UBound(settings, 1)
With Me
info(index) = .Controls(settings(index, 1))
End With
Next index
End With
With Sheets(SHEET_DATA)
.Range("A" & getLR(.Name, "A") + 1).Resize(, UBound(info)) = info
End With
End Sub
Private Sub UserForm_Initialize()
Dim settings As Variant
Dim index As Long
Dim label As MSForms.label
Dim textbox As MSForms.textbox
currentTopPos = 20
With Sheets(SHEET_SETTINGS)
settings = .Range("A2:D" & getLR(.Name, "A")).Value
For index = LBound(settings, 1) To UBound(settings, 1)
With Me
Set label = .Controls.Add("Forms.Label.1")
With label
.Left = UI_LEFT
.Top = currentTopPos
.Width = settings(index, 4)
.Height = UI_LINE_HEIGHT
currentTopPos = .Top + .Height + UI_GAP
.Caption = settings(index, 2)
End With
Set textbox = .Controls.Add("Forms.textbox.1")
With textbox
.Name = settings(index, 1)
.Left = UI_LEFT
.Top = currentTopPos
.Width = settings(index, 4)
.Height = settings(index, 3) * UI_LINE_HEIGHT
If settings(index, 3) > 1 Then .MultiLine = True
currentTopPos = .Top + .Height + UI_GAP
End With
.Height = 300
.Width = 380
.Caption = "http://hocexcel.online"
End With
Next index
End With
With cmdSaveData
.Top = currentTopPos
.Left = 310 - cmdSaveData.Width
End With
Set label = Nothing
Set textbox = Nothing
End Sub
Private Sub UserForm_Activate()
With Me
.ScrollBars = fmScrollBarsVertical
.ScrollHeight = currentTopPos * 1.2
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.