当我尝试将 Sheet1 中的数据插入 Sheet2 时,我的 VBA 脚本出错。脚本代码仅提供“案例 2-3”行号,第一个“案例”不输入到工作表 2。想知道 VBA 脚本中还应该包含什么来完成流程?
我的 VBA 脚本:
Sub CopyFromSheet1()
Dim i As Long
For i = 1 To Sheet1.Cells(Sheet1.Rows.Count, 6).End(xlUp).Row ' Last Cell of Column F
Select Case CStr(Sheet1.Cells(i, 3).Value) ' Looks at the Value in Column C
Case "Due From"
Sheet2.Cells(22, 3).Value = Sheet1.Cells(i, 6).Value
Case "TOTAL1"
Sheet2.Cells(23, 3).Value = Sheet1.Cells(i, 6).Value
Case "TOTAL2"
Sheet2.Cells(24, 3).Value = Sheet1.Cells(i, 6).Value
End Select
Next i
End Sub