|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub CommandButton1_Click()
On Error Resume Next
Dim r, i, m, n, j
Dim arr, brr
With Sheet1
r = .Cells(.Rows.Count, "F").End(3).Row
arr = .Range("A3:AE" & r)
End With
Dim str1 As String, str2 As String, str3 As String, str4 As String, str5 As String, str6 As String
str1 = Sheet7.Range("F1").Value
str2 = Sheet7.Range("F2").Value
str3 = Sheet7.Range("F3").Value
str4 = Sheet7.Range("H1").Value
str5 = Sheet7.Range("H2").Value
str6 = Sheet7.Range("H3").Value
If str1 = "" And str2 = "" And str3 = "" And str4 = "" Then MsgBox "至少输入一个查询条件才查询相应数据!", vblnformation, "系统提示 ": Exit Sub
ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2) + 1)
Sheet7.Columns("H:H").NumberFormatLocal = "@" '无效果
For i = 1 To UBound(arr)
If (str1 = "" Or (arr(i, 3) Like "*" & str1 & "*" And str1 <> "")) And _
(str2 = "" Or (arr(i, 4) Like "*" & str2 & "*" And str2 <> "")) And _
(str3 = "" Or (arr(i, 16) Like "*" & str3 & "*" And str3 <> "")) And _
(str4 = "" Or (arr(i, 24) Like "*" & str4 & "*" And str4 <> "")) And _
(str5 = "" Or (arr(i, 26) Like "*" & str5 & "*" And str5 <> "")) And _
(str6 = "" Or (arr(i, 27) Like "*" & str6 & "*" And str6 <> "")) Then
m = m + 1
For j = 1 To UBound(arr, 2)
brr(m, 1) = m
arr(m, 7) = CStr(arr(m, 7))
brr(m, j + 1) = arr(i, j)
Next
End If
Next
If m > 0 Then
Range("6:10000").Clear
Range("A6").Resize(m, UBound(brr, 2)) = brr
Range("I2") = m & "条"
Else
MsgBox "抱歉,没有符合条件的数据 , 请您再次查证所录入的查询条件是否存在 !", vblnformation, "系统提示"
Range("6:10000").Clear
End If
End Sub
导出身份证后不能正确显示号,大神看看有什么办法解决
Sheet7.Columns("H:H").NumberFormatLocal = "@" '无效果
|
|