繁体   English   中英

如何使用10,000行限制转置Excel?

[英]How do I Transpose with the 10,000 row limits of excel?

我正在尝试对“ B”列的所有元素进行转置,但是想跳过一行然后抓取下4个并将它们粘贴到同一列中。 我如何才能使“ B”列的所有循环都跳过第5行并自动将范围更改为下一个打开的单元格或“范围”,而无需手动分别键入每个范围?

Range("B12:B16").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True
    Range("B18:B22").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("A3").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True
    Range("B24:B28").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("A4").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True

您可以尝试使用此代码,我已经在1万多个单元格上的Excel 2010中对其进行了测试:

Sub SkipOnFive()

Dim inRow As Integer 'number of row in source worksheet
Dim outRow As Integer 'number of row in output worksheet
Dim outCol As Integer 'number of column in output worksheet

Dim strTemp As String

inRow = 1 'this is your start row on input sheet
outRow = 1 ' this is your start row on output sheet

Do
    For outCol = 1 To 4
        strTemp = Cells(inRow, 2).Value
        Worksheets(2).Cells(outRow, outCol).Value = strTemp
       inRow = inRow + 1
    Next
    outRow = outRow + 1
    inRow = inRow + 1
Loop While strTemp <> vbNullString 'vbnullstring is kind of empty string, but it does not use any resources to create
End Sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM