2

以下はVBAで有効です

Range("K1:K5")

以下が有効でないのはなぜですか?

Dim nb As Long
Range("K1:K" + nb)

Range("K1:K" & nb) も試し、String代わりに nb a を作ってみました。

4

2 に答える 2

4

の値nb = 0とExcelの行はで始まるため1

これを試して

Dim nb As Long
Dim Rng As Range

nb = 2
Set Rng = Range("K1:K" & nb)
于 2013-10-25T12:52:44.777 に答える
0

nb の値が何かわかりません。

RowIndex と ColumnIndex が整数である Cells(RowIndex, ColumnIndex) 表記を使用してみてください。

Sub RangeExemple()

Dim colIndex, colIndex2, rowIndex, rowIndex2 As Integer

colIndex = 7
colIndex2 = colIndex
rowIndex = 1
rowIndex2 = 5

Range(Cells(rowIndex, colIndex), Cells(rowIndex2, colIndex2)).Interior.ColorIndex = 37

サブ終了

本当は何がしたいの?

于 2013-10-25T13:14:14.993 に答える