【发布时间】:2014-05-20 18:21:45
【问题描述】:
任何帮助将不胜感激。这个 excel vb 脚本在名为“Order sheet -SL”的工作表中搜索 X 或 x,然后将特定的单元格值插入到新工作表中。除了在实际值的新工作表插入中插入 0(零)之外,它运行良好
源代码:
Sub SOLIMPORT2(worksheetname As String)
Dim Order As Worksheet
Dim SolomonImport As Worksheet
Set Order = Worksheets("Order sheet -SL")
Set SolomonImport = Worksheets(worksheetname)
Dim i As Integer
Dim j As Integer
i = 8
j = 3
Do
If Order.Cells(i, 6) = "x" Or Order.Cells(i, 6) = "X" Then
SolomonImport.Range("A1") = "LEVEL0"
SolomonImport.Range("B1") = "SO #:"
SolomonImport.Range("C1") = "PSO"
SolomonImport.Range("A3") = "LEVEL1"
SolomonImport.Cells(j, 2) = Order.Cells(i, 11)
SolomonImport.Cells(j, 3) = Order.Cells(i, 13)
'Range("I10").Value = Range("F10").Value
SolomonImport.Cells(j, 4) = Order.Cells(i, 14)
SolomonImport.Cells(j, 5) = Order.Cells(i, 15)
'SolomonImport.Cells(j, 31) = Order.Range("F1")
'SolomonImport.Cells(j, 32) = "TC-50"
'SolomonImport.Cells(j, 3) = Order.Cells(i, 11)
'SolomonImport.Cells(j, 5) = "0"
'SolomonImport.Cells(j, 13) = "0"
'SolomonImport.Cells(j, 37) = Order.Cells(i, 8)
'SolomonImport.Cells(j, 38) = Order.Cells(i, 10)
j = j + 1
End If
i = i + 1
If Order.Range("A" & Trim(Str(i))) = "SHEET TAB Z" Then
Exit Do
End If
Loop
End Sub
示例: Ordered Sheet –SL 选项卡包含源数据:
RELEASE PART # QUANTITY UNIT COST EXTENDED COST x MX418 S/C 1 147.9 147.9 x MX418 D/C 4 178.5 714 x MX418 S/C 2 147.9 295.8
新工作表和输出:
新工作表:上面黄色突出显示的单元格在下面显示为 0。单位成本单元格包含此公式 (=A!L9),扩展成本单元格公式是数量乘以单位成本。
MX418 S/C 1 0 1
MX418 D/C 4 0 0
MX418 S/C 2 0 0
谢谢。
【问题讨论】: