|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
各位前辈,我在读这个程序,偶像知道黄色底色标出的go to line1该怎么看,是直接跳到下面的line1程序吗,那个程序是不是就包含两个步骤,y=27,w=0
Dim i As Long, j As Long, total As Double, y As Double, x As Double, w As Double, y1 As Double, y2 As Double,Dim count As Long
For i = 23 To Range("a21").CurrentRegion.Rows.count
total = Cells(i, 22)
On Error Resume Next
y = Application.WorksheetFunction.Match(Cells(i, 26), Range("a21:ez21"), False)
x = Application.WorksheetFunction.Match(Cells(i, 10), Range("z1:z20"), False)
w = Range("j22:j" & i - 1).Find(Cells(i, 10), after:=Cells(23, 10), LookIn:=xlFormulas, lookat:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
If Cells(i, 26) <> "" Then
count = 0
For j = y To Range("aa21").CurrentRegion.Columns.count '
If total > Cells(i, 11) * Cells(x, j) Then
If count = 0 Then
Cells(i, j) = Cells(i, 11) * (Cells(x, j) - Cells(i, 12))
Else
Cells(i, j) = Cells(i, 11) * Cells(x, j)
End If
If Cells(i, j) >= 0 Then Cells(i, j).Interior.Color = 15773696
total = total - Cells(i, j)
Else
Cells(i, j) = total
If Cells(i, j) >= 0 Then Cells(i, j).Interior.Color = 15773696
GoTo line1
End If
count = count + 1
Next
End If
y1 = Application.WorksheetFunction.Match(Cells(w, 24), Range("a21:ez21"), False)
y2 = Application.WorksheetFunction.Match(Cells(i - 1, 23), Range("a21:ez21"), False) + Cells(i, 25) + 1
If Cells(i, 7) <> Cells(i - 1, 7) Then
If w = 0 Then
y = 27 '需要考虑逻辑关系。同一品种,先后生产.已解决!
Else
y = y1
End If
ElseIf w = 0 Then
y = y2
Else
y = Application.WorksheetFunction.Max(y1, y2)
End If
count = 0
For j = y To Range("aa21").CurrentRegion.Columns.count
If total > Cells(i, 11) * Cells(x, j) Then
If w = 0 Then
If count = 0 Then
Cells(i, j) = Cells(i, 11) * (Cells(x, j) - Cells(i, 12))
Else
Cells(i, j) = Cells(i, 11) * Cells(x, j)
End If
Else
If count = 0 Then
Cells(i, j) = Cells(i, 11) * (Application.WorksheetFunction.RoundDown((Cells(x, j) - (Cells(w, j) / Cells(w, 11))), 0) - Cells(i, 12))
Else
Cells(i, j) = Cells(i, 11) * Application.WorksheetFunction.RoundDown((Cells(x, j) - (Cells(w, j) / Cells(w, 11))), 0)
End If
End If
If Cells(i, j) >= 0 Then Cells(i, j).Interior.Color = 15773696
total = total - Cells(i, j)
Else
Cells(i, j) = total
If Cells(i, j) >= 0 Then Cells(i, j).Interior.Color = 15773696
GoTo line1
End If
count = count + 1
Next
line1:
y = 27
w = 0
Next
With Range("aa1:ez20").Interior
.Pattern = xlNone
End With
With Range("aa23").CurrentRegion
.WrapText = False
.ShrinkToFit = True
End With
Application.ScreenUpdating = True
End Sub
|
|