|
Private Sub CommandButton1_Click()
Dim str As String
Dim a As Integer
Dim i As Integer
Dim ii As Integer
Dim sl As Integer
Dim FirstT As Boolean '标头设置一次
Application.ScreenUpdating = False
If Sheets("面板").Range("M1") = 1 Then
Call UnProed
Call 清除面板
str = Me.ComboBox1.Text
a = Sheets("数据库").Range("A65536").End(xlUp).Row
sl = 0
For i = 2 To a
If CStr(Sheets("数据库").Cells(i, 1)) = str Then
If FirstT = False Then
Sheets("面板").Range("C3") = Sheets("数据库").Cells(i, 1) '订单编号
Sheets("面板").Range("C4") = Sheets("数据库").Cells(i, 3) '客户
Sheets("面板").Range("C6") = Sheets("数据库").Cells(i, 4) '日期
Sheets("面板").Range("H4") = Sheets("数据库").Cells(i, 15) '电话
Sheets("面板").Range("C5") = Sheets("数据库").Cells(i, 16) '地址
FirstT = True
End If
For ii = 5 To 14
Sheets("面板").Cells(sl + 8, ii - 4) = Sheets("数据库").Cells(i, ii) '数据
Next
sl = sl + 1
If sl > 54 Then MsgBox ("送货单行数不够,原因可能是有人工到数据库里的数据!请清查!"): Exit Sub
End If
Next
Application.ScreenUpdating = True
Unload Me
Else
Call UnProed
Call 清除面板
str = Me.ComboBox1.Text
a = Sheets("出货数据").Range("A65536").End(xlUp).Row
sl = 0
For i = 2 To a
If CStr(Sheets("出货数据").Cells(i, 1)) = str Then
If FirstT = False Then
Sheets("面板").Range("I3") = Sheets("出货数据").Cells(i, 1) '送货单编号
Sheets("面板").Range("C3") = Sheets("出货数据").Cells(i, 5) '订单编号
Sheets("面板").Range("C4") = Sheets("出货数据").Cells(i, 3) '客户
Sheets("面板").Range("C6") = Sheets("出货数据").Cells(i, 4) '日期
Sheets("面板").Range("H4") = Sheets("出货数据").Cells(i, 16) '电话
Sheets("面板").Range("C5") = Sheets("出货数据").Cells(i, 17) '地址
Sheets("面板").Range("E3") = Sheets("出货数据").Cells(i, 18) '业务员
FirstT = True
End If
For ii = 6 To 15
Sheets("面板").Cells(sl + 8, ii - 5) = Sheets("出货数据").Cells(i, ii) '数据
Next
sl = sl + 1
If sl > 54 Then MsgBox ("送货单行数不够,原因可能是有人工到数据库里的数据!请清查!"): Exit Sub
End If
Next
Application.ScreenUpdating = True
Unload Me
End If
End Sub
Private Sub UserForm_Initialize() '加载列表框数据
ComboBox1.Clear
If Sheets("面板").Range("M1") = 1 Then
For i = 2 To Sheets("数据库").[a65536].End(xlUp).Row
If WorksheetFunction.CountIf(Sheets("数据库").Range("a3:a" & i), Sheets("数据库").Range("a" & i)) = 1 Then
ComboBox1.AddItem Sheets("数据库").Range("a" & i)
End If
Next i
Else
For i = 2 To Sheets("出库数据").[a65536].End(xlUp).Row
If WorksheetFunction.CountIf(Sheets("出货数据").Range("a3:a" & i), Sheets("出货数据").Range("a" & i)) = 1 Then
ComboBox1.AddItem Sheets("出货数据").Range("a" & i)
End If
Next i
End If
End Sub
|
|