|
用Col+Xx找单元格,死活搞不定。MergeAreas简单多了。
- Set oRng = RowRng(ii, 1).Resize(, RowRng.Columns.Count)
- TabArr = TabDataArr(oRng, AreasRng, Arr1, Arr2)
- Function TabDataArr(Rng As Range, AreasRng As Range, RowArr, ColArr)
- ''
- Dim Rr, Cc
- Dim Arr, Str, oDate As Date
- Dim oRng As Range
- Dim Sht As Worksheet
- Set Sht = Rng.Parent
- With AreasRng
- ''
- ''Debug.Print .Areas.Count = UBound(RowArr) + 1
- ''Debug.Print .Areas(1).MergeArea.Columns.Count = UBound(ColArr) + 1
- Rr = UBound(RowArr) + 1
- Cc = UBound(ColArr) + 1
-
- ReDim Arr(Rr, Cc)
- ''
- For jj = 1 To Cc
- Arr(0, jj) = ColArr(jj - 1)
- Next jj
- ''
- For ii = 1 To Rr
- Set oRng = .Areas(ii)
- ''
- Arr(ii, 0) = RowArr(ii - 1)
- ''
- For jj = 1 To Cc
- Str = Sht.Cells(Rng.Row, oRng(, jj).Column)
-
- If IsDate(Arr(ii, jj)) Then
- Arr(ii, jj) = Format(Str, "h:m:ss")
- oDate = Arr(ii, jj)
- Else
- Arr(ii, jj) = Str
- End If
- Next jj
- Next ii
- End With
- TabDataArr = Arr
- End Function
复制代码
|
|