EXCEL 表格根据内容转置 但是效果不好
- Public Sub mm()
- Dim numcol As Integer
- Dim numrow As Long
- 'Dim mypos As Integer
- Dim i As Long
- Dim myRange As Range
- Set myRange = Application.InputBox("选择区域", Type:=8)
- myRange.Name = "数据"
- Range("数据").Select
- numrow = Selection.Rows.Count '数据区的行数
- numcol = Selection.Columns.Count '数据区的列数
- Range("a1").Select
-
-
- For Each Rng In myRange
- Rng.Cut
- ActiveSheet.Paste
- Selection.Offset(, numcol).Select
-
- If (InStr(Rng, "begin") = 0) Then '判断是否要换行 Cells(Rng + 1, 0).Select
- Else: Selection.Offset(1, -1 * Rng.Column).Select
- End If
-
- Next Rng
-
- End Sub
|