標題:
EXCEL VAB問題
[打印本頁]
作者:
andysara9
時間:
2022-4-7 14:49
標題:
EXCEL VAB問題
小弟首次在這版上發言,如果有解釋不清楚或者不對的地方再請包涵,
日前使用一個前輩做好的VBA,執行後顯示"執行階段錯誤13",有高手可以幫忙看一下問題卡在哪裡嗎?程式碼如下:(標示顏色的是偵錯後顯示的)
Sub Update_費用工作底稿()
Dim Counter As Long
Dim myRecord(6) As Variant
Dim n As Long
Dim myLineNumber As Long
Dim ws As Worksheet
Dim SumBegin As String
Dim SumEnd As String
Set ws = ActiveSheet
Range("A9:F45").Select
Selection.ClearContents
Sheets("z2-DATABASE_SR_XMAST").Select
Range("A2").Select
Counter = 0
n = 0
myLineNumber = 0
Do Until IsEmpty(ActiveCell.Offset(Counter, 0).Value)
If UCase(ActiveCell.Offset(Counter, 0).Value) = UCase(ws.Range("N2")) Then
For n = 0 To 5
myRecord(n) = ActiveCell.Offset(Counter, n + 2).Value
Next
For n = 0 To 5
ws.Select
Range("A9").Select
ActiveCell.Offset(myLineNumber, n).Value = myRecord(n)
Next
myLineNumber = myLineNumber + 1
Sheets("z2-DATABASE_SR_XMAST").Select
Range("A2").Select
Else
End If
Counter = Counter + 1
Loop
ws.Select
Range("A9").Select
For n = 3 To 4
SumBegin = ActiveCell.Offset(0, n).Address
SumEnd = ActiveCell.Offset(myLineNumber + 1, n).Address
Next
End Sub
作者:
Porsche69
時間:
2022-4-8 06:31
回復
1#
andysara9
你可以試著把
If UCase(ActiveCell.Offset(Counter, 0).Value) = UCase(ws.Range("N2")) Then
改成
If UCase(ActiveCell.Offset(Counter, 0).Value) = UCase(ws.Range("N2")
.Value
) Then
再試看看可不可以。
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)