2016-12-18 7 views
1

文字列を範囲に変換する方法を知りたいと思います。ここにコードがあります。VBA - 文字列を範囲に変換する

Dim operation As Integer 
operation = 3 
Dim contaminant As Integer 
contaminant = 3 
Dim countL2 As Integer 'Initial row 
countL2 = 13 
Dim countC2 As Integer 'Initial column 
countC2 = 3 

Dim maxC As String 
maxC = (countC2+operation) & (countL2) & ":" & (countC2+operation) & (countL2 + contaminant - 1) 
Dim maxRange As Range 
Set maxRange = sh2.Range(maxC) 

動作しません。私はそれがRangeに文字列を変換していないためだと思います。誰も私を助けることができますか?ありがとうございました。

答えて

0

文字列を使用して範囲を指定しようとする場合は、R1C1表記を使用しない限り、列を数値として指定することはできません。生成する文字列は"613:615"で、Excelでは意味がありません。

は、以下の

Set maxRange = sh2.Range(sh2.Cells(countL2, countC2 + operation), _ 
         sh2.Cells(countL2 + contaminant - 1, countC2 + operation)) 
+0

を使用して、あなたはそれが完璧に動作YowE3Kありがとうございました。 – vbalearner

関連する問題