|
- Sub 求教()
- Dim sh As Worksheet, lngRow As Long, lngCol As Long, arrData As Variant
- Dim arrChar As Variant, arrResult As Variant
- Dim strChars As String, strNums As String
- Dim bytChar() As Byte, lngID As Long
- Dim RowID As Long, ColID As Long
-
- Set sh = Sheets("Sheet1")
- lngRow = sh.Range("C" & Rows.Count).End(xlUp).Row
-
- arrData = sh.Range("C2:G" & lngRow)
- ReDim arrChar(1 To UBound(arrData), 1 To 1) As String
- ReDim arrResult(1 To 10, 1 To 10) As Integer '1-10 行,A-J列
-
- For lngRow = 1 To UBound(arrData)
- strChars = StrConv(Trim(arrData(lngRow, 1)), vbFromUnicode) 'C列 B区
- strNums = StrConv(Trim(arrData(lngRow, 5)), vbFromUnicode) 'G列 数字
-
- bytChar = strChars
- lngID = bytChar(0): ColID = lngID - 64
- arrChar(lngRow, 1) = Chr(lngID)
-
- bytChar = strNums
- For lngCol = LBound(bytChar) To UBound(bytChar)
- lngID = bytChar(lngCol): RowID = lngID - 48
- If RowID = 0 Then RowID = 10
- arrResult(RowID, ColID) = arrResult(RowID, ColID) + 1
- Next
- Next
-
- sh.Range("H2").Resize(UBound(arrChar), 1) = arrChar
-
- sh.Range("P1").Resize(1, 10) = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
- sh.Range("O2").Resize(10, 1) = Application.WorksheetFunction.Transpose(Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0))
- sh.Range("P2").Resize(10, 10) = arrResult
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|