大大們, 好
下列是一個表單程式, 小弟想把表單輸入的資料, 存於另一張工作表2, 並從工作表2, a欄開始, 請教大大們如何修改, 謝謝謝!
Private Sub SaveData_Click()
With UserForm1
co = Trim(.Company.Value)
ad = Trim(.Address.Value)
yn = MsgBox("是否5組資料完整輸入", vbYesNo)
cts = Array(Company, Address, TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox7, TextBox8)
ctsname = Array(.Label1.Caption, .Label2.Caption, .Label3.Caption, .Label4.Caption, .Label5.Caption, .Label6.Caption, .Label7.Caption, .Label8.Caption, .Label9.Caption, .Label10.Caption)
k = 0
With ActiveSheet
ar = Array(co, ad, TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox7, TextBox8)
For i = 36 To 48 Step 3
If ar(j) <> "" Then
If Not .Columns(i).Find(ar(j), lookat:=xlWhole) Is Nothing Then
MsgBox "資料重複!! " & ctsname(j), vbCritical + vbOKOnly, "請檢查"
Exit Sub
Else
r = .Cells(65536, i).End(xlUp).Offset(1, 0).Row
.Cells(65536, i).End(xlUp).Offset(1, 0).Resize(, 2) = Array(ar(j), ar(j + 1))
End If
End If
j = j + 2
Next
End With
If MsgBox("是否繼續輸入?", vbQuestion + vbYesNo, "請確認") = vbNo Then
Unload UserForm1
Else
Unload Me
UserForm1.Show
UserForm1.Company.SetFocus
[a1].Select
End If
End With
End Sub