2017-10-26 10 views
0

かなり基本的なVBAを使用していますが、SAP \ BPC、EPMアドイン。実行時エラー '1004':オブジェクト_ワークシートのメソッド範囲が失敗しました。EPM BPC VBA

エラーセクション:

For Each CurCell In Input_Sheet.Range(Input_Sheet.Range("SPREAD_COLUMN"), Input_Sheet.Range("SPREAD_COLUMN").Offset(Input_Sheet.Cells.SpecialCells(xlCellTypeLastCell).Row, 0)) 

コード: 以下のコード見つけてください

Private Function AFTER_REFRESH() 
    ' Apply the in-cell drop-downs (validations) for the spreads 

    Dim CurCell As Range 

    Application.EnableEvents = False 
    Application.ScreenUpdating = False 

    UnProtect_Sheet 

    For Each CurCell In Input_Sheet.Range(Input_Sheet.Range("SPREAD_COLUMN"), Input_Sheet.Range("SPREAD_COLUMN").Offset(Input_Sheet.Cells.SpecialCells(xlCellTypeLastCell).Row, 0)) 
     If Not CurCell.Font.Bold Then 
      With CurCell.Validation ' apply validation (drop-down) to spread column 
       .Delete 
       .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=SPREAD_METHODS" 
       .InCellDropdown = True 
      End With 

     End If 
    Next 


    If LockWorkbook Then 
     Protect_Sheet 
    End If 

    Application.EnableEvents = True 
    Application.ScreenUpdating = True 

End Function 

をあなたの助けとよろしくお願いします。

答えて

0

イミディエイトウィンドウ(Ctrl + G)から、Input_Sheet.Range(Input_Sheet.Range("SPREAD_COLUMN"), Input_Sheet.Range("SPREAD_COLUMN").Offset(Input_Sheet.Cells.SpecialCells(xlCellTypeLastCell).Row, 0))行をコンポーネントに分割して、エラーの発生場所を確認します。

?Input_Sheet.Range("SPREAD_COLUMN").Address 

、その後

?Input_Sheet.Cells.SpecialCells(xlCellTypeLastCell).Row 

、その後、上記の

Input_Sheet.Range("SPREAD_COLUMN").Offset(Input_Sheet.Cells.SpecialCells(xlCellTypeLastCell).Row, 0) 

いずれかの操作を行い失敗し、問題を解決するために軌道に乗ってあなたを配置します。たとえば、Input_Sheetに「SPREAD_COLUMN」の範囲はありません。おそらく最後に使用された行がオフセットが1'048'576行の制限を超えてプッシュするのに十分な大きさです。たぶんInput_Sheet.Range( "SPREAD_COLUMN")は、縦方向にオフセットすることができない列全体です。

0

プロシージャを実行して値を返さないため、コードをFunctionではなくSubに変更する方がよい場合があります。

手順の外でinput_sheetを宣言しましたか?

Option explicit 

Private Sub AFTER_REFRESH() 
'Apply the in-cell drop-downs (validations) for the spreads 

Application.EnableEvents = False 
Application.ScreenUpdating = False 

UnProtect_Sheet 

If not (Input_Sheet is nothing) then 

Dim CurCell As Range 

On error resume next 
Set CurCell = input_sheet.range("SPREAD_COLUMN") 
ON error GOTO 0 

If not (curcell is nothing) then 

For Each CurCell In Input_sheet.Range(Input_sheet.range("SPREAD_COLUMN"), Input_sheet.Range("SPREAD_COLUMN").Offset(Input_Sheet.Cells.SpecialCells(xlCellTypeLastCell).Row, 0) 

If Not CurCell.Font.Bold Then 

With CurCell.Validation ' apply validation (drop-down) to spread column 
.Delete 
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=SPREAD_METHODS" 
.InCellDropdown = True 
End With 

End If 
Next cell 
Else 
Msgbox("Input_Sheet exists, but does not contain the range SPREAD_COLUMN.") 
End if 

    Else 
    Msgbox("Input_Sheet does not exist") 
    End if 

If LockWorkbook Then 
Protect_Sheet 
End If 

Application.EnableEvents = True 
Application.ScreenUpdating= True 

End Function 
関連する問題