2016-12-18 2 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

관련 문제