- 帖子
- 31
- 主題
- 10
- 精華
- 0
- 積分
- 45
- 點名
- 0
- 作業系統
- WinXP
- 軟體版本
- OFFICE2007
- 閱讀權限
- 10
- 性別
- 女
- 註冊時間
- 2013-8-2
- 最後登錄
- 2016-12-9
 
|
回復 9# GBKEE
真的很謝謝GB大大每次幫忙小妹解決問題,實在是很汗顏,學習VBA一段時間了,很多應用都做的不好,
真需要用上時,常常只能求助,買了一堆書想了解應用,但書中的解說實在多數於實際應用時有很大的差異
謝謝版大不厭其煩幫忙解決問題。
其中有一段 不太能了解意思,如下紅字部份
16.Private Sub ComboBox1_Change()
17. Dim AR, i As Integer
18. AR = Array(TextBox1, TextBox2, TextBox3)
19. With ComboBox1
20. If .ListIndex > -1 Then
21. For i = 0 To UBound(AR)
22. AR(i).Value = .List(.ListIndex, i + 1)
23. Next
24. '一堆的的控制項寫不完
25. ' TextBox1 = .List(.ListIndex, 1) '這幾行不論是註解掉及未註解都不影響正常作業,他的作用為?
26. ' TextBox2 = .List(.ListIndex, 2)
27. ' TextBox3 = .List(.ListIndex, 3)
28. End If
29. End With
30.End Sub
另實在很不好意思,有一工作上的急需,可否請版大指點如何修改
在分類資料中要重覆輸入的字時無法將資料輸入至資料庫,按下新增後自動清除
資料庫不會新增資料,及LISTBOX.2也不會顯示。
在設定中並未有看過濾重覆項目的地方,不知如何修改能實現功能
比如 原來已有C+於清單2了,要再加一個C+上去同時顯示於清單2上,但其內容有不同只有清單名稱相同
謝謝版大~- Private Sub CommandButton10_Click()
- With UserForm1
- If ListBox1.Text = "" Then
- MsgBox "您還未選定品項喔~", vbCritical + vbOKOnly, "請輸入"
- .TextBox12.SetFocus
- Exit Sub
- End If
- mycase = Trim(.TextBox12.Text)
- If mycase = "" Then
- MsgBox "請於輸入分類清單欄內輸入要新增分類名稱~", vbCritical + vbOKOnly, "請輸入"
- .TextBox12.SetFocus
- Exit Sub
- Else
-
- .ListBox2.AddItem mycase
- .TextBox12.Value = ""
- .TextBox12.SetFocus
- .Frame1.Enabled = False
- .Frame3.Enabled = False
- .CommandButton6.Enabled = False
- .CommandButton11.Enabled = False
- .CommandButton12.Enabled = True
- End If
- End With
- Call CommandButton12_Click
- End Sub
- Private Sub CommandButton12_Click()
- Dim cell As Range, rng As Range
- With UserForm1
- .Frame1.Enabled = True
- .Frame3.Enabled = True
- .CommandButton6.Enabled = True
- .CommandButton6.Enabled = True
- .CommandButton11.Enabled = True
- .CommandButton12.Enabled = True
- myname = .ListBox1.Text
- Set cell = Sheets("資料庫").Columns("A").Find(myname, lookat:=xlWhole)
- If cell Is Nothing Then
- er = Sheets("資料庫").[B65536].End(3).Row + 1
- Sheets("資料庫").Cells(er, 1).Value = .TextBox1.Text
- Sheets("資料庫").Cells(er, 2).Resize(.ListBox2.ListCount, 1) = .ListBox2.List
- .TextBox1.Value = ""
- Else
- r1 = Split(d1(myname), "-")(0)
- r2 = Split(d1(myname), "-")(1)
- Set rng = Sheets("資料庫").Range("B" & r1 & ":B" & r2)
- For i = 0 To .ListBox2.ListCount - 1
- Set cell = rng.Find(.ListBox2.List(i), lookat:=xlWhole)
- If cell Is Nothing Then
- r2 = r2 + 1
- Sheets("資料庫").Rows(r2).EntireRow.Insert
- Sheets("資料庫").Cells(r2, 2).Value = .ListBox2.List(i)
- End If
- Next i
- End If
- Call UpdateBox
- .CommandButton12.Enabled = False
- End With
- End Sub
複製代碼
TEST4.rar (42.96 KB)
|
|