行全体を選択

選択範囲の最も上の行全体を選択するマクロを作成しました。

sub ma0040_Select_Rows
Dim maCurrentC as Object
Dim maCurrentS as Object
 maCurrentC = ThisComponent.CurrentController
 maCurrentS = ThisComponent.CurrentSelection
 maCurrentC.Select(maCurrentS.Rows.getByIndex(0))
end sub




マクロの機能(添字は0から始ります)
 選択範囲の最も上の行全体を選択します。

マクロの説明
 maCurrentS.Rows.getByIndex(0) : 選択範囲の最も上の行全体     
 maCurrentS.Rows.getByIndex(maCurrentS.Rows.Count-1)) : 選択範囲の最も下の行全体  

 maCurrentS.Rows.getByIndex(Row_i) の場合
 Row_i=0,から選択範囲の行数−1 の数値を指定することが出来ます。

 maCurrentS.Rows.getByIndex(0) と
 maCurrentS.Rows.getByIndex(0).getCellRangeByPosition(0,0,255,0) の
 マクロの実行結果は、同じになります。

 maCurrentS.Rows.getByIndex(0).getCellRangeByPosition(0,0,9,0) の場合は、
 選択範囲の最も上の行(Row_i)の先頭からセル10個分("A"Row_i+1 から "J"Row_i+1 まで) となります。

 maCurrentS.Rows.getByIndex(0)
  .getCellRangeByPosition(Start_Column_i,Start_Row_i,End_Column_i,End_Row_i)の場合は
 Start_Column_i=0,...,255 ,Start_Row_i=0
 End_Column_i =0,...,255 ,End_Row_i =0 の数値を指定することが出来ます。
 但し、Start_Column_i<=End_Column_i となります。


Excelでは、下記のようになります。
 Sub X0040_Select_Rows()
 With Application.ActiveWindow.Selection
  ThisWorkbook.ActiveSheet.Rows(CStr(.Row) & ":" & CStr(.Row)).Select
 End With
 End Sub


又、「Application.ActiveWindow.Selection」を「Selection」に
 「ThisWorkbook.ActiveSheet.Rows」を「Rows」に変更した標準版では、下記のようになります。
 Sub X0041_Select_Rows()
 With Selection
  Rows(CStr(.Row) & ":" & CStr(.Row)).Select
 End With
 End Sub


選択範囲の最も上の行(Row_i)の先頭からセル10個分("A"Row_i から "J"Row_i まで) の場合は
 Sub X0042_Select_Rows()
 With Selection
  Rows(CStr(.Row) & ":" & CStr(.Row)).Columns("A:J").Select
 End With
 End Sub


サンプルマクロ(Calc)

「ファイルのダウンロード」について 一旦ファイルを保存して
「ma0040_select_rows.zip」を「ma0040_select_rows.sxc」に変更後、実行して下さい。
2006年11月03日(金) 10:54:43 Modified by zizidai_3373




スマートフォン版で見る