|
|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码如下。。。
Sub test()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
t = Timer
Dim wb As Workbook, sht As Worksheet, sh As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("sheet1")
r = sht.Cells(Rows.Count, 1).End(3).Row
arr = sht.[a1].Resize(r)
For Each shp In sht.Shapes
If shp.Name Like "按钮*" = False And shp.Name Like "Button*" = False Then
shp.Delete
End If
Next
For i = 2 To r
If hz(arr(i, 1)) = False Then
sht.Cells(i, 1).RowHeight = 50
With sht.OLEObjects.Add(classtype:="BARCODE.BarCodeCtrl.1")
.Object.Style = 7
.Object.Value = arr(i, 1)
.Height = sht.Cells(i, 1).Height - 2
.Width = sht.Cells(i, 1).Offset(, 1).Width - 2
.Left = sht.Cells(i, 1).Offset(, 1).Left + 0.5
.Top = sht.Cells(i, 1).Top + 0.5
End With
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "共耗时:" & Format(Timer - t, "0.0000") & " 秒!!!", 64
End Sub
Function hz(s)
'验证汉字
With CreateObject("vbscript.regexp")
.Pattern = "[一-龥]"
.Global = False
.IgnoreCase = True
.MultiLine = False
If .test(s) Then
hz = True
End If
End With
End Function
|
评分
-
1
查看全部评分
-
|