이렇게하면 각각의 문자열 표현을 얻은 다음 배열에 저장합니다. 그것은 몇 가지 가정을합니다. (시트가 존재하고 첫 번째는 인덱스 순서에서 첫 번째이며 인덱스와 관련하여 모든 것을 원한다는 것을 나타냅니다.) 그러나 상황에 따라 다를 수 있습니다.
Sub Parse()
Dim wbk As Workbook
' Arbitrary array size of 10 to store the ranges (as an example)
Dim myRanges(10) As Variant
Set wbk = ActiveWorkbook
' Split the string at the !
s = "Sheet1:Sheet3!A1:D10"
s = Split(s, "!")
' Range is the second element of the split (A1:D10)
TargetRange = s(1)
' The first contains the sheets, so split on the :
SheetNames = Split(s(0), ":")
' These sheets are the lower/upper bounds, so use their indices in a loop
' that cycles over the sheets in between them (inclusive)
j = 0 ' This is for the array - you may not need it
For i = wbk.Sheets(SheetNames(0)).Index To wbk.Sheets(SheetNames(1)).Index
' Range is the concatenation of the sheet at this index and the target range
Set Rng = Range(wbk.Sheets(i).Name & "!" & TargetRange)
' Drop it in to our array (or handle how you want)
myRanges(j) = Rng
j = j + 1
Next i
End Sub
물론 감각, 정말 감사합니다! –
@ManofLeng 아무런 문제가 없습니다. 도움이되기를 바랍니다! – RocketDonkey
+1 멋지게 완료되었습니다. – brettdj