|
- Sub 记录倒序()
- Dim shResult As Worksheet, lngRows As Long
- Dim shData As Worksheet, ColID As Long, arrVal As Variant
-
- Set shResult = Sheets("记录倒序")
- lngRows = shResult.UsedRange.Rows.Count
- shResult.Rows("3:" & lngRows).ClearContents
-
- Set shData = Sheets("记录")
-
- For ColID = 1 To 90
- arrVal = GetReverse(shData, ColID)
- If IsArray(arrVal) Then shResult.Cells(3, ColID).Resize(UBound(arrVal), 1) = arrVal
- Next
- End Sub
- Function GetReverse(sh As Worksheet, ColID As Long, Optional Row_StartID As Long = 22) As Variant
- Dim lngRows As Long, arrTmp As Variant, arrReturn As Variant, lngID As Long
-
- lngRows = sh.Cells(Rows.Count, ColID).End(xlUp).Row - 2 '减去末尾2行
- If lngRows <= Row_StartID Then Exit Function '无数据
-
- arrTmp = sh.Range(sh.Cells(Row_StartID, ColID), sh.Cells(lngRows, ColID))
-
- ReDim arrReturn(LBound(arrTmp) To UBound(arrTmp), 1 To 1)
-
- lngID = LBound(arrTmp)
- For lngRows = UBound(arrTmp) To LBound(arrTmp) Step -1
- arrReturn(lngID, 1) = arrTmp(lngRows, 1)
- lngID = lngID + 1
- Next
-
- GetReverse = arrReturn
- End Function
复制代码 |
|