abdo meghari
Active Member
- Joined
- Aug 3, 2021
- Messages
- 465
- Office Version
- 2019
hi
I got some help from Mr.Fluff to copy data from userform contains many multiple textboxes & comboboxes by using loop
. the problem is after copy data from userform to sheet in this part of code
this problem shows error mismatch when some textboxes are empty . so it should copy without any problem even some textboxes are empty
thanks in advance
I got some help from Mr.Fluff to copy data from userform contains many multiple textboxes & comboboxes by using loop
Code:
Private Sub CommandButton1_Click()
Dim i As Long
With Sheets("Invoice")
.Range("e5").MergeArea = Me.TextBox1.Value
.Range("e8").MergeArea = Me.TextBox2.Value
For i = 3 To 6
.Cells(i + 13, 1).Value = Me.Controls("TextBox" & i)
Next i
For i = 7 To 18
.Cells(((i - 7) Mod 4) + 16, Int((i - 7) / 4) + 5).Value = Me.Controls("Textbox" & i)
Next i
For i = 1 To 12
.Cells(((i - 1) Mod 4) + 16, Int((i - 1) / 4) + 2).Value = Me.Controls("ComboBox" & i)
Next i
End With
TextBox15.Value = Me.TextBox7.Value * Me.TextBox11.Value
TextBox16.Value = Me.TextBox8.Value * Me.TextBox12.Value
TextBox17.Value = Me.TextBox9.Value * Me.TextBox13.Value
TextBox18.Value = Me.TextBox10.Value * Me.TextBox14.Value
End Sub
VBA Code:
TextBox15.Value = Me.TextBox7.Value * Me.TextBox11.Value
TextBox16.Value = Me.TextBox8.Value * Me.TextBox12.Value
TextBox17.Value = Me.TextBox9.Value * Me.TextBox13.Value
TextBox18.Value = Me.TextBox10.Value * Me.TextBox14.Value
thanks in advance