Excel-VBA RangeとCells

Macroを編集してVBAを書き上げるとき、一番戸惑うのはRangeです。
Excelでは、Rangeでセルの指定を行います。
Range(”A1:X10”)のような表記となります。
しかし、このままでは固定したRangeならともかく、変数を使っての指定は
出来ません。

こんな時はCellsを使います
Cellsは以下のよう使い方ですが、Excelの標準のA1の表記は X-Yであるのに、
Cellsは Y-X であることに注意が必要です。

'-------------------------------------------------------------------
Sheets("SKD1").Select

Range(Cells(St_n, 3), Cells(En_n, 33)).Select

Selection.ClearContents
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWindow.SmallScroll Down:=-6
Range("A1").Select

'---------------------------------------------------------------

わかお かずまさ
VegaSystems

📷📷📷📷📷📷
#LAN_PRO
#Bloguru
#kuma

People Who Wowed This Post

×
  • If you are a bloguru member, please login.
    Login
  • If you are not a bloguru member, you may request a free account here:
    Request Account
This user only allows bloguru members to make comments.
If you are a bloguru member, please login.
Login
If you are not a bloguru member, you may request a free account here:
Request Account