|
代码如下。。。。
Sub test() '增加数据
Dim wb As Workbook, sht As Worksheet, sh As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("油墨调配录入")
Set sh = wb.Sheets("油墨调配使用数据库")
r = sht.[a17].End(3).Row
rr = sh.[a1048576].End(3).Row
If rr > 2 Then xuhao = sh.Cells(rr, 1).Value Else rr = 3: xuhao = 0
arr = sht.[a3:o16]
s = Split("b3 f3 m3 o3 b4 f4 i4 l4 n4")
Set Rng = sht.[a8:k16,m8:o16]
ReDim brr(0, 8)
ReDim crr(1 To 9, 1 To 11)
ReDim drr(1 To 9, 0)
For i = 0 To UBound(brr, 2)
brr(0, i) = sht.Range(s(i))
Next
For i = 6 To UBound(arr)
If arr(i, 1) <> Empty Then
n = n + 1
For j = 1 To UBound(crr, 2)
If j <= 6 Then crr(n, j) = arr(i, j)
If j = 7 Then crr(n, j) = arr(i, 9)
If j = 8 Then crr(n, j) = arr(i, 11)
If j > 8 Then crr(n, j) = arr(i, 3 + j)
drr(n, 0) = xuhao + n
Next
End If
Next
With sh
.Cells(rr + 1, 1).Resize(n) = drr
.Cells(rr + 1, 2).Resize(n, 9) = brr
.Cells(rr + 1, 11).Resize(n, 11) = crr
End With
For i = 0 To UBound(s)
sht.Range(s(i)) = Empty
Next
Rng.Value = Empty
Beep
End Sub
Sub test1() '查询
Dim wb As Workbook, sht As Worksheet, sh As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("油墨调配录入")
Set sh = wb.Sheets("油墨调配使用数据库")
rr = sh.[a1048576].End(3).Row
arr = sh.[a1].CurrentRegion
Set Rng = sht.[a8:k16,m8:o16]
ReDim brr(1 To 1000, 1 To 2)
ReDim crr(1 To 1000, 1 To 11)
ReDim drr(0, 8)
s = sht.[b3] & sht.[o3]
For i = 4 To UBound(arr)
ss = arr(i, 2) & arr(i, 5)
If ss = s Then
n = n + 1
For j = 0 To 8
drr(0, j) = arr(i, j + 2)
Next
For j = 1 To 10
If j <= 6 Then crr(n, j) = arr(i, j + 10)
If j = 7 Then crr(n, 9) = arr(i, 17)
If j = 8 Then crr(n, 11) = arr(i, 18)
If j > 8 Then brr(n, j - 8) = arr(i, j + 11)
Next
End If
Next
Rng.Value = Empty
With sht
.Cells(8, 1).Resize(n, 11) = crr
.Cells(8, 13).Resize(n, 2) = brr
End With
s = Split("b3 f3 m3 o3 b4 f4 i4 l4 n4")
For i = 0 To UBound(drr, 2)
sht.Range(s(i)) = drr(0, i)
Next
Beep
End Sub
|
评分
-
1
查看全部评分
-
|