|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码如下,也请专家指点一下,代码是否可以优化的更简单一点,个人感觉很繁索,但又想不到好的方法。
Sub 发票号序号会计期()
Dim w, y, v
w = Application.CountA(Sheets("明细记录").Columns(2))
y = Application.CountA(Sheets("明细记录").Rows(2))
v = Application.CountA(Sheets("领用明细").Columns(2))
Set Rng = Sheets("领用明细").Cells.Find("发票号")
If Not Rng Is Nothing Then
co = Rng.Column
End If
Set Rng3 = Sheets("领用明细").Cells.Find("计划行号")
If Not Rng3 Is Nothing Then
co1 = Rng3.Column
End If
h = co - co1 + 1
Set Rng4 = Sheets("明细记录").Cells.Find("发票号")
If Not Rng4 Is Nothing Then
co2 = Rng4.Column
End If
For m = 1 To y
rng1 = Sheets("明细记录").Cells(2, m)
If rng1 <> "发票号" Then GoTo 100
For n = 3 To w
rng2 = Sheets("明细记录").Cells(n, 1)
rng5 = Sheets("明细记录").Cells(n, co)
rng5 = WorksheetFunction.VLookup(rng2, Sheets("领用明细").Range("u2:au" & v), h, 0)
If rng5 = "" Then GoTo 100
Next
100:
Next
End Sub
|
|