vba代码封装,请高手把下面的代码改成封装dll的代码 30
PublicelAsObjectSubtest123()'OnErrorGoToeendSetel=GetObject(,"Excel.Application")'创建e...
Public el As Object
Sub test123()
'On Error GoTo eend
Set el = GetObject(, "Excel.Application") '创建excel对象
Dim rngs As Range, arr()
Top:
Set rngs = el.Application.InputBox("请输入身份证号码所在的区域", "提示", , , , , , 8)
If rngs.Columns.Count > 1 Then
MsgBox "只支持一列身份证号码的计算,请重新输入"
GoTo Top
End If
arr = Intersect(rngs, el.ActiveSheet.UsedRange)
For i = 1 To UBound(arr)
Select Case Len(arr(i, 1))
Case 15
arr(i, 1) = Format("19" & Mid(arr(i, 1), 7, 6), "0000-00-00")
Case 18
arr(i, 1) = Format(Mid(arr(i, 1), 7, 8), "0000-00-00")
Case 0
arr(i, 1) = ""
Case Else
arr(i, 1) = "身份证号码有误"
End Select
Next
Set rngs = el.Application.InputBox("请选择生日的导出区域", "提示", , , , , , 8)
el.rngs.Resize(UBound(arr)) = arr
'eend:
End Sub 展开
Sub test123()
'On Error GoTo eend
Set el = GetObject(, "Excel.Application") '创建excel对象
Dim rngs As Range, arr()
Top:
Set rngs = el.Application.InputBox("请输入身份证号码所在的区域", "提示", , , , , , 8)
If rngs.Columns.Count > 1 Then
MsgBox "只支持一列身份证号码的计算,请重新输入"
GoTo Top
End If
arr = Intersect(rngs, el.ActiveSheet.UsedRange)
For i = 1 To UBound(arr)
Select Case Len(arr(i, 1))
Case 15
arr(i, 1) = Format("19" & Mid(arr(i, 1), 7, 6), "0000-00-00")
Case 18
arr(i, 1) = Format(Mid(arr(i, 1), 7, 8), "0000-00-00")
Case 0
arr(i, 1) = ""
Case Else
arr(i, 1) = "身份证号码有误"
End Select
Next
Set rngs = el.Application.InputBox("请选择生日的导出区域", "提示", , , , , , 8)
el.rngs.Resize(UBound(arr)) = arr
'eend:
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询