そのオブジェクトを完全に修飾することなく、With
ステートメントのオブジェクトをブロック内から呼び出されるプロシージャのパラメーターとして使用することは可能ですか? またはWith
に相当する可能性があります。this
me
With thisThing.thatThing.otherThing.myObject
MySub [?] ' How do I specify myObject as the parameter?
MySub This 'No, that's not it...
MySub Me 'Not this either... what is it?
'Of course I could do this:
MySub thisThing.thatThing.otherThing.myObject
'But I'd prefer not having to fully qualify myObject like that
....
End With
例 :
With Worksheet.Range("A1:E4")
Call SubName(<range from with>)
End With
<range from with>
を指しているだろうWorksheet.Range("A1")
編集:
単一のセル範囲の範囲を指定することで、単一の値を暗示していたようです。悪いです。具体的には、呼び出しているプロシージャに範囲を解析しようとしています (指定された範囲の周りにいくつかの境界線を描画します)。
私の実際のコード:
With ReportSheet
// Call drawBorder(.Range(.Cells(j + 9, 2), .Cells(k + 9, 2))) <--What I have to do right now
With .Range(.Cells(j + 9, 2), .Cells(k + 9, 2))
//Call drawBorder(<the specified range above> <--What I want to do
//Other code
End With
End With
Sub drawBorder(drawRange As Range)
With drawRange
//Various code
End With
End Sub