harimao
New Member
- Joined
- Oct 23, 2020
- Messages
- 4
- Office Version
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
- MacOS
as I still newbie for VBA, i created save button but after click it then came these error, highlight last End Sub
VBA Code:
Private Sub CommandButton1_Click()
If TextBox1.Text <> Empty And TextBox2.Text <> Empty And TextBox4.Text <> Empty Then
If Empty And TextBox5.Text <> Empty And TextBox6.Text <> Empty Then
If Empty And TextBox7.Text <> Empty And TextBox8.Text <> Empty Then
If Empty And TextBox9.Text <> Empty And TextBox10.Text <> Empty Then
If Empty And TextBox11.Text <> Empty And TextBox12.Text <> Empty And TextBox13.Text <> Empty Then
If Empty And TextBox14.Text <> Empty And TextBox15.Text <> Empty And TextBox16.Text <> Empty Then
If Empty And TextBox17.Text <> Empty And TextBox18.Text <> Empty And TextBox19.Text <> Empty Then
If Empty And TextBox20.Text <> Empty And TextBox21.Text <> Empty And TextBox22.Text <> Empty Then
If Empty And TextBox23.Text <> Empty And TextBox24.Text <> Empty And TextBox25.Text <> Empty Then
If Empty And TextBox26.Text <> Empty And TextBox27.Text <> Empty And TextBox28.Text <> Empty Then
If Empty And TextBox29.Text <> Empty And TextBox30.Text <> Empty And TextBox31.Text <> ComboBox1.Text <> Empty Then
TextBox3 = Sheets("Sheet1").Range("a65536").End(3).Value + 1
Else
MsgBox "Missing Information", vbExclamation
CommandButton2_Click
Exit Sub
End If
With Sheets("Sheet1")
For Each bul In Sheets("Sheet1").Range("b2:b" & Range("b65536").End(3).Row)
If bul = ComboBox1 Then
Label5.Visible = True
Exit Sub
End If
Next bul
For Each bul In .Range("b2:b" & Range("b65536").End(3).Row)
If bul = ComboBox1 Then
bul.Offset(i, -1).Activate
bul.Offset(i, 1) = TextBox1
bul.Offset(i, 2) = TextBox2
bul.Offset(i, 3) = TextBox4
bul.Offset(i, 4) = TextBox5
bul.Offset(i, 5) = TextBox6
bul.Offset(i, 6) = TextBox7
bul.Offset(i, 7) = TextBox8
bul.Offset(i, 8) = TextBox9
bul.Offset(i, 9) = TextBox10
bul.Offset(i, 10) = TextBox11
bul.Offset(i, 11) = TextBox12
bul.Offset(i, 12) = TextBox13
bul.Offset(i, 13) = TextBox14
bul.Offset(i, 14) = TextBox15
bul.Offset(i, 15) = TextBox16
bul.Offset(i, 16) = TextBox17
bul.Offset(i, 17) = TextBox18
bul.Offset(i, 18) = TextBox19
bul.Offset(i, 19) = TextBox20
bul.Offset(i, 20) = TextBox21
bul.Offset(i, 21) = TextBox22
bul.Offset(i, 22) = TextBox23
bul.Offset(i, 23) = TextBox24
bul.Offset(i, 24) = TextBox25
bul.Offset(i, 25) = TextBox26
bul.Offset(i, 26) = TextBox27
bul.Offset(i, 27) = TextBox28
bul.Offset(i, 28) = TextBox29
bul.Offset(i, 29) = TextBox30
bul.Offset(i, 30) = TextBox31
bul.Offset(i, -1) = TextBox3
Exit For
Else
.Range("a65536").End(3).Offset(1, 0) = .Range("a65536").End(3) + 1
.Range("a65536").End(3).Offset(0, 1) = ComboBox1
.Range("a65536").End(3).Offset(0, 2) = TextBox1
.Range("a65536").End(3).Offset(0, 3) = TextBox2
.Range("a65536").End(3).Offset(0, 4) = TextBox4
.Range("a65536").End(3).Offset(0, 5) = TextBox5
.Range("a65536").End(3).Offset(0, 6) = TextBox6
.Range("a65536").End(3).Offset(0, 7) = TextBox7
.Range("a65536").End(3).Offset(0, 8) = TextBox8
.Range("a65536").End(3).Offset(0, 9) = TextBox9
.Range("a65536").End(3).Offset(0, 10) = TextBox10
.Range("a65536").End(3).Offset(0, 11) = TextBox11
.Range("a65536").End(3).Offset(0, 12) = TextBox12
.Range("a65536").End(3).Offset(0, 13) = TextBox13
.Range("a65536").End(3).Offset(0, 14) = TextBox14
.Range("a65536").End(3).Offset(0, 15) = TextBox15
.Range("a65536").End(3).Offset(0, 16) = TextBox16
.Range("a65536").End(3).Offset(0, 17) = TextBox17
.Range("a65536").End(3).Offset(0, 18) = TextBox18
.Range("a65536").End(3).Offset(0, 19) = TextBox19
.Range("a65536").End(3).Offset(0, 20) = TextBox20
.Range("a65536").End(3).Offset(0, 21) = TextBox21
.Range("a65536").End(3).Offset(0, 22) = TextBox22
.Range("a65536").End(3).Offset(0, 23) = TextBox23
.Range("a65536").End(3).Offset(0, 24) = TextBox24
.Range("a65536").End(3).Offset(0, 25) = TextBox25
.Range("a65536").End(3).Offset(0, 26) = TextBox26
.Range("a65536").End(3).Offset(0, 27) = TextBox27
.Range("a65536").End(3).Offset(0, 28) = TextBox28
.Range("a65536").End(3).Offset(0, 29) = TextBox29
.Range("a65536").End(3).Offset(0, 30) = TextBox30
.Range("a65536").End(3).Offset(0, 31) = TextBox31
CommandButton2_Click
ComboBox1.Clear
UserForm_Initialize
Exit For
End If
End Sub
Last edited by a moderator: