- Private Sub CommandButton1_Click()
- Dim ARR
- Dim N1, X, Y As Long
- Dim SHT1 As Worksheet
- Dim BOX1, BOX2, STRX As String
- Dim BOOL As Boolean
-
- BOX1 = UserForm1.ComboBox1.Value
- BOX2 = UserForm1.ComboBox2.Value
- Set SHT1 = Sheets("成品编号")
-
-
- If BOX1 <> "" And BOX2 <> "" Then
- ARR = Split("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z", ",")
- BOOL = False
- For X = 0 To UBound(ARR)
- For Y = 0 To UBound(ARR)
- STRX = BOX2 & BOX1 & ARR(X) & ARR(Y)
- Set C = SHT1.Range("A:A").Find(STRX, , LOOKAT:=xlWhole)
- If C Is Nothing Then
- N1 = SHT1.Cells(65536, 1).End(xlUp).Row + 1
- SHT1.Cells(N1, 1) = STRX
- BOOL = True
- Exit For
- End If
- Next
- If BOOL = True Then Exit For
- Next
- If BOOL = False Then
- MsgBox "PCB板类型和客户编号:已经全部占用,换个编号试试!"
- End If
- Else
- MsgBox "PCB板类型和客户编号不能为空"
- End If
-
- End Sub
复制代码 |