|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub FillData()
Dim x, m, n, j
Dim arr, brr(1 To 4000, 1 To 8)
Dim starday, endday, qd
Sheets("抗压强度评定").Unprotect ("123456")'密码
Sheets("试块强度输入").Unprotect ("123456")'密码
starday = Sheets("抗压强度评定").[o3]
endday = Sheets("抗压强度评定").[o4]
qd = Sheets("抗压强度评定").[p4]
arr = Sheets("试块强度输入").[a1].CurrentRegion
For x = 2 To UBound(arr)
If CDate(arr(x, 2)) >= CDate(starday) And CDate(arr(x, 2)) <= CDate(endday) Then
If arr(x, 11) = qd Then
If arr(x, 9) <> "" Then
n = n + 1
If n Mod 8 = 0 Then
j = (n \ 8)
m = 8
Else
j = (n \ 8) + 1
m = n Mod 8
End If
brr(j, m) = arr(x, 8)
End If
End If
End If
Next
Sheets("抗压强度评定").[e5:l35].ClearContents
If n > 0 And n <= 248 Then
Sheets("抗压强度评定").[e5].Resize(j, 8) = brr
Else
MsgBox "提取到的数据共:" & n & "个;超过248个数量!"
GoTo 100:
Exit Sub
End If
100:
Sheets("抗压强度评定").Protect ("123456")'密码
Sheets("试块强度输入").Protect ("123456")'密码
End Sub
|
|