返回列表 上一主題 發帖

[發問] 請教新增表單編號問題

  1. Private Sub CommandButton2_Click()
  2. Dim A As Range, Rng As Range
  3. If TextBox1.Text = "" Then
  4.     MsgBox "請輸入正確的值"
  5. Else
  6. Application.ScreenUpdating = False
  7. Worksheets("工作表2").Range("A:G").Clear
  8. With Worksheets("工作表1")
  9. Set A = .Cells.Find(TextBox1, Lookat:=xlPart)
  10. If Not A Is Nothing Then
  11.   first = A.Address
  12. Do
  13. If Rng Is Nothing Then
  14.    Set Rng = .Cells(A.Row, 1).MergeArea
  15.    Else
  16.    Set Rng = Union(Rng, .Cells(A.Row, 1).MergeArea)
  17. End If
  18. Set A = .Cells.FindNext(A)
  19. Loop While Not A Is Nothing And A.Address <> first
  20. Rng.EntireRow.Copy Sheets("工作表2").[A1]
  21. Else
  22. MsgBox "無符合資料"
  23. End If
  24. End With
  25. End If
  26. Application.ScreenUpdating = True
  27. End Sub
複製代碼
回復 7# afu9240
學海無涯_不恥下問

TOP

        靜思自在 : 並非有錢魷是快樂,問心無愧心最安。
返回列表 上一主題