|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton1_Click()
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
If OptionButton1.Value = False And OptionButton2.Value = False And OptionButton3.Value = False And OptionButton4.Value = False Then MsgBox "请选择查询选项!": Exit Sub
If TextBox1.Text = "" And TextBox2.Text = "" And TextBox3.Text = "" And TextBox2.Text = "" Then MsgBox "请输入查询条件!": Exit Sub
With Sheets("入库明细")
r1 = .Cells(Rows.Count, 7).End(xlUp).Row
ar1 = .Range("a1:l" & r1)
End With
With Sheets("每日库存结余")
r2 = .Cells(Rows.Count, 5).End(xlUp).Row
ar2 = .Range("a1:j" & r2)
End With
With Sheets("出库明细")
r3 = .Cells(Rows.Count, 7).End(xlUp).Row
ar3 = .Range("a1:bi" & r3)
End With
With Sheets("退货明细")
r4 = .Cells(Rows.Count, 3).End(xlUp).Row
ar4 = .Range("a1:ay" & r4)
End With
With Sheets("订单总台账")
r = .Cells(Rows.Count, 3).End(xlUp).Row
.Range("d3:q" & r) = Empty
ar = .Range("a2:q" & r)
For i = 2 To UBound(ar)
If Trim(ar(i, 3)) <> "" Then
d(Trim(ar(i, 3))) = i
End If
Next i
If OptionButton1.Value = True Then
tj = TextBox1.Text
ElseIf OptionButton2.Value = True Then
tj = TextBox2.Text
ElseIf OptionButton3.Value = True Then
tj = TextBox3.Text
ElseIf OptionButton4.Value = True Then
tj = TextBox4.Text
End If
For i = 2 To UBound(ar1)
If Trim(ar1(i, 7)) <> "" Then
xh = d(Trim(ar1(i, 7)))
If xh <> "" Then
If Trim(ar1(i, 4)) <> "" Then
If IsDate(ar1(i, 4)) Then
If OptionButton1.Value = True Then
rqq = DatePart("ww", rq)
ElseIf OptionButton2.Value = True Then
rqq = Year(rq)
ElseIf OptionButton3.Value = True Then
rqq = Month(rq)
ElseIf OptionButton4.Value = True Then
rqq = Format(ar1(i, 4), "yyyy/m/d")
End If
If rqq = tj Then
ar(xh, 11) = ar(xh, 11) + ar1(i, 11)
End If
End If
End If
End If
End If
Next i
For i = 2 To UBound(ar2)
If Trim(ar2(i, 5)) <> "" Then
xh = d(Trim(ar2(i, 5)))
If xh <> "" Then
If Trim(ar2(i, 4)) <> "" Then
If IsDate(ar2(i, 4)) Then
rq = Format(ar2(i, 4), "yyyy/m/d")
zc = DatePart("ww", rq)
ny = Year(rq)
yf = Month(rq)
rq = rq
If zc = tj Then
ar(xh, 12) = ar2(i, 12)
End If
End If
End If
End If
End If
Next i
For i = 2 To UBound(ar3)
If Trim(ar3(i, 7)) <> "" Then
xh = d(Trim(ar3(i, 7)))
If xh <> "" Then
If Trim(ar3(i, 32)) <> "" Then
If IsDate(ar3(i, 32)) Then
rq = Format(ar3(i, 32), "yyyy/m/d")
zc = DatePart("ww", rq)
ny = Year(rq)
yf = Month(rq)
rq = rq
If zc = tj Then
If Trim(ar3(i, 3)) = "天猫" Then
ar(xh, 14) = ar(xh, 14) + ar3(i, 11)
Else
ar(xh, 15) = ar(xh, 15) + ar3(i, 11)
End If
End If
End If
End If
End If
End If
Next i
For i = 2 To UBound(ar4)
If Trim(ar4(i, 3)) <> "" Then
xh = d(Trim(ar4(i, 3)))
If xh <> "" Then
If Trim(ar4(i, 1)) <> "" Then
If IsDate(ar4(i, 1)) Then
rq = Format(ar4(i, 1), "yyyy/m/d")
zc = DatePart("ww", rq)
ny = Year(rq)
yf = Month(rq)
rq = rq
If zc = tj Then
If Trim(ar4(i, 23)) = "天猫" Then
ar(xh, 16) = ar(xh, 16) + ar4(i, 17)
Else
ar(xh, 16) = ar(xh, 16) + ar4(i, 17)
End If
End If
End If
End If
End If
End If
Next i
.Range("a2:q" & r) = ar
End With
MsgBox "ok!"
End Sub
Private Sub OptionButton1_Click()
If OptionButton1 = True Then
Label1.Visible = True
TextBox1.Visible = True
Label2.Visible = False
TextBox2.Visible = False
Label3.Visible = False
TextBox3.Visible = False
Label4.Visible = False
TextBox4.Visible = False
End If
End Sub
Private Sub OptionButton2_Click()
If OptionButton2 = True Then
Label2.Visible = True
TextBox2.Visible = True
Label1.Visible = False
TextBox1.Visible = False
Label3.Visible = False
TextBox3.Visible = False
Label4.Visible = False
TextBox4.Visible = False
End If
End Sub
Private Sub OptionButton3_Click()
If OptionButton3 = True Then
Label3.Visible = True
TextBox3.Visible = True
Label1.Visible = False
TextBox1.Visible = False
Label2.Visible = False
TextBox2.Visible = False
Label4.Visible = False
TextBox4.Visible = False
End If
End Sub
Private Sub OptionButton4_Click()
If OptionButton4 = True Then
Label4.Visible = True
TextBox4.Visible = True
Label2.Visible = False
TextBox2.Visible = False
Label3.Visible = False
TextBox3.Visible = False
Label1.Visible = False
TextBox1.Visible = False
End If
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
Label1.Visible = False
TextBox1.Visible = False
Label2.Visible = False
TextBox2.Visible = False
Label3.Visible = False
TextBox3.Visible = False
Label4.Visible = False
TextBox4.Visible = False
End Sub
|
|