1

アプリケーションの.Selectionプロパティで選択された領域を取得できます。

(私はPythonを使用してExcel comインターフェイスにアクセスしています)

たとえば、ユーザーが選択した行と列の数を知りたい

input:
    user has selected A1:G8
output:
    the selected range starts from Column 1 (by selection.Column)
    the selected range starts from Row 1 (by selection.Column)
    the selected range is spanning 7 rows (by ?)
    the selected range is spanning 8 columns (by ?)

MSDN のRange インターフェイスを見ていますが、プロパティはこの問題には役立たないようです。

4

1 に答える 1

0

VBA から、次のようなことができます。

Debug.Print Selection.Rows.Count
Debug.Print Selection.Columns.Count
Debug.Print Selection.Row
Debug.Print Selection.Column

A1:G8 が選択されている場合、これは戻ります

8 
7 
1 
1 

それはPythonに簡単に翻訳できますか>

于 2013-03-18T09:17:14.030 に答える