点击(最多18字)
这是我们今天简单模拟的数据源,我们一起来看看在Excel当中有几种方法可以实现条形码的创建
这样是不是简单了很多,什么鬼都不用设置,就成功的实现了条形码的生成。想要这个字体的小伙伴,可以后台私信回复"zi体",即可获得
优点:好像没有,反正我感觉用起来也不太方便
Sub 一维码()
Application.ScreenUpdating = False
On Error Resume Next
Dim rng As Range, rngData As Range, sht As Worksheet
Set rngData = Application.InputBox("请选择需要生成条形码的区域 ", , , , , Type:=8)
Set sht = rngData.Parent
Set rngData = Intersect(rngData, sht.UsedRange)
If rngData Is Nothing Or Err Then
MsgBox "你未选择有效的区域,程序退出 "
Exit Sub
End If
sht.Select
For Each shp In sht.Shapes
If InStr(shp.Name, "BarCodeCtrl") Then shp.Delete
Next
For Each rng In rngData
With sht.OLEObjects.Add(classtype:="BARCODE.BarCodeCtrl.1")
.Object.Style = 6
.LinkedCell = rng.Address
.Height = rng.Height - 2
.Width = rng.Width - 2
.Left = rng.Left
.Top = rng.Top
End With
Next
Application.ScreenUpdating = True
End Sub
直接来看看效果
同样也是快速的生成了条形码,并且VBA代码的亮点就是,条形码的下面还有数字!