我遇到了创建循环的问题,我可以将" delivery qty"在每个部分下面的黄点。
我想要做的是循环整个表格,并做出"交付数量"的总和。并将其插入我在每个供应商编号后插入的黄色空白区域。
Sub SumOfDeliveryQty()
Dim ws As Excel.Worksheet
Dim lRow As Long
Dim lStartSection As Long
Set ws = Application.Sheets("PO Copy")
lRow = 2
lStartSection = 0
'Loop through the used range in the spreadsheet
Do While lRow <= ws.UsedRange.Rows.Count
'If we are at the start of a section record the row.
If lStartSection = 0 And ws.Range("F" & lRow).Value <> "" Then
lStartSection = lRow
End If
'Check if we are at the bottom of a section
If ws.Range("F" & lRow).Value = "Total" Then
ws.Range("F" & lRow).Value = "=SUM(F" & lStartSection & ":F" & lRow - 1 & ")"
'Set this back to zero so we know that we are no longer in a section
lStartSection = 0
End If
lRow = lRow + 1
Loop
End Sub