|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Public Sub X1()
- Dim wb As Workbook, sht As Worksheet
- Set wb = Application.ThisWorkbook
- Set sht = wb.Worksheets(1)
- With sht
- Set Rng = .Range("A1").CurrentRegion
- arr = Rng.Value
- End With
- Dim br()
- ReDim br(1 To (UBound(arr) - 1) * 9 + 1, 1 To 6)
- br(1, 1) = "学部"
- br(1, 2) = "班级"
- br(1, 3) = "学生姓名"
- br(1, 4) = "证件号"
- br(1, 5) = "学科"
- br(1, 6) = "分数"
- r = 1
- For i = 2 To UBound(arr)
- For j = 5 To UBound(arr, 2)
- r = r + 1
- br(r, 1) = arr(i, 1)
- br(r, 2) = arr(i, 2)
- br(r, 3) = arr(i, 3)
- br(r, 4) = "'" & arr(i, 4)
- br(r, 5) = arr(1, j)
- br(r, 6) = arr(i, j)
- Next j
- Next i
- Set sht = wb.Worksheets(2)
- With sht
- .Range("a1").Resize(UBound(br), UBound(br, 2)).Value = br
- End With
- End Sub
复制代码 |
|