複数の選択範囲のアドレスを取得。 EXCEL VBA [マクロ]
昨日は15分の仮眠のつもりが完全睡眠になってしまいました。。。。
以前、時々使っていたのですが、最近再度必要になり使わせて頂きました。(_ _)
Sub Sample()
Dim i, AreaCount As Integer, NRow As Integer, NColumn As Integer
'不連続の範囲がいくつあるか数えます
AreaCount = Selection.Areas.Count
MsgBox "選択されている範囲は" & AreaCount & "つに別れています"
'選択されている範囲を表示します
For i = 1 To AreaCount
MsgBox "範囲" & i & "は" & Selection.Areas(i).Address
Next
'不連続領域のはじめのセルアドレスを表示します
For i = 1 To AreaCount
NRow = Selection.Areas(i).Row
NColumn = Selection.Areas(i).Column
MsgBox "範囲" & i & "のはじめのセルは" & Cells(NRow, NColumn).Address
Next
'不連続領域の終わりのセルアドレスを表示します
For i = 1 To AreaCount
NRow = Selection.Areas(i).Row + Selection.Areas(i).Rows.Count - 1
NColumn = Selection.Areas(i).Column + Selection.Areas(i).Columns.Count - 1
MsgBox "範囲" & i & "の終わりのセルは" & Cells(NRow, NColumn).Address
Next
End Sub
クリック募金 各サイトに直接つながります。以前、時々使っていたのですが、最近再度必要になり使わせて頂きました。(_ _)
Sub Sample()
Dim i, AreaCount As Integer, NRow As Integer, NColumn As Integer
'不連続の範囲がいくつあるか数えます
AreaCount = Selection.Areas.Count
MsgBox "選択されている範囲は" & AreaCount & "つに別れています"
'選択されている範囲を表示します
For i = 1 To AreaCount
MsgBox "範囲" & i & "は" & Selection.Areas(i).Address
Next
'不連続領域のはじめのセルアドレスを表示します
For i = 1 To AreaCount
NRow = Selection.Areas(i).Row
NColumn = Selection.Areas(i).Column
MsgBox "範囲" & i & "のはじめのセルは" & Cells(NRow, NColumn).Address
Next
'不連続領域の終わりのセルアドレスを表示します
For i = 1 To AreaCount
NRow = Selection.Areas(i).Row + Selection.Areas(i).Rows.Count - 1
NColumn = Selection.Areas(i).Column + Selection.Areas(i).Columns.Count - 1
MsgBox "範囲" & i & "の終わりのセルは" & Cells(NRow, NColumn).Address
Next
End Sub
http://www.cosmo-oil.co.jp/kankyo/charity/
http://www.able.co.jp/company/contribute/new-action/clickable/
http://kakaku.com/donation/
http://www.j-energy.co.jp/cp/society/click_tp.php
http://www.chintai.net/contribution/index.html
http://www.nittsu.co.jp/corporate/contribution/1click.html
http://www.daiichisankyo.co.jp/csr/clickdonation/index.html
http://www.nippn.co.jp/csr/unicef/oneclick.html
飛び地のセルアドレス取得に大変参考になりました。
ありがとうございます。
by eden (2014-03-19 16:46)