下面的VBScript代碼讓我在該行的錯誤」獲得一個VBScript運行時錯誤
.Range(.Cells(lRow, lCol), .Cells(lRow, lCol + 3)).Delete Shift:=xlToLeft
正確
.Range(.Cells(lRow, lCol), .Cells(lRow, lCol + 3)).Delete(-4159)
錯誤是: 「預期的陳述結束」
代碼
Sub DataShiftFromRightToLeft(Ob6)
Dim lCol,COL_FIRST,startCol
Dim NUM_TASKS:NUM_TASKS=36
COL_FIRST = objExcel1.Application.WorksheetFunction.Match("Parent Business Process ID", ob6.Rows(1), 0)
COL_FIRST=COL_FIRST+1
'Set wst = Ob6.ActiveSheet
With ob6.ActiveSheet
For lRow = 2 To .UsedRange.Rows.Count
lTask = 1
Do While lTask <= NUM_TASKS
lCol = COL_FIRST + (lTask - 1) * 4
If Len(.Cells(lRow, lCol).Value) = 0 And _
Len(.Cells(lRow, lCol + 1).Value) = 0 And _
Len(.Cells(lRow, lCol + 2).Value) = 0 And _
Len(.Cells(lRow, lCol + 3).Value) = 0 Then
' make sure there is something to the right to shift over
If .Cells(lRow, lCol).End(xlToRight).Column < .Columns.Count Then
' delete the empty cells and shift everything left``
.Range(.Cells(lRow, lCol), .Cells(lRow, lCol + 3)).Delete Shift:=xlToLeft
Else
' force the loop to the next row
lTask = NUM_TASKS + 1
End If
Else
lTask = lTask + 1
End If
Loop
Next lRow
End With
End Sub
任何人都可以幫我嗎? –
@TukalRakshit - 請做一些研究(提示:使用VBScript和圓括號中的參數調用Subs和Functions),使您的調用完全正確。 –