|
楼主 |
发表于 2013-2-8 12:55
|
显示全部楼层
Sub ys()
Dim fx As Worksheet
Set fx = Worksheets("分析")
Dim x As Integer
x = 3
Dim y As Integer
y = Application.WorksheetFunction.Match(Worksheets("分析").Cells(1, 4), Worksheets("单店损益表-当月-预算").Range("c7:dq7"), 0)
On Error Resume Next
Do While Cells(x, 2) <> ""
If Application.WorksheetFunction.IsError(Application.WorksheetFunction.VLookup(Cells(x, 2), Worksheets("单店损益表-当月-预算").Range("c7:dq241"), y, 0)) _
Then fx.Cells(x, 5) = "" Else fx.Cells(x, 5) = Application.WorksheetFunction.VLookup(Cells(x, 2), Worksheets("单店损益表-当月-预算").Range("c7:dq241"), y, 0)
x = x + 1
Loop
Dim x1 As Integer
x1 = 3
Dim y1 As Integer
y1 = Application.WorksheetFunction.Match(Worksheets("分析").Cells(1, 4), Worksheets("单店损益表-当月-去同").Range("c7:dq7"), 0)
On Error Resume Next
Do While Cells(x, 2) <> ""
If Application.WorksheetFunction.IsError(Application.WorksheetFunction.VLookup(Cells(x1, 2), Worksheets("单店损益表-当月-去同").Range("c7:dq241"), y1, 0)) _
Then fx.Cells(x1, 6) = "" Else fx.Cells(x, 6) = Application.WorksheetFunction.VLookup(Cells(x1, 2), Worksheets("单店损益表-当月-去同").Range("c7:dq241"), y1, 0)
x1 = x1 + 1
Loop
End Sub
我将两个SUB 合在一起只执行了第一个循环,第二个循环就不执行了!求解 |
|