答案 0 :(得分:1)
有些vba可能适合您。这会将文本块复制到一列中,并从每个块的第一行开始向右转置它们。
Sub TransposeFilenames()
Dim lRow As Long, fRow As Long, col As Long
Dim copyRng As Range
fRow = 2 ' First row with data, change as needed
col = 3 ' Column with filenames, change as needed
With ThisWorkbook.Worksheets("Sheet1") ' Change to your sheet name
lRow = .Cells(.Rows.Count, col).End(xlUp).Row
Do
Set copyRng = .Range(.Cells(fRow, col), .Cells(fRow, col).End(xlDown))
copyRng.Copy
copyRng.Cells(1).Offset(, 1).PasteSpecial Paste:=xlPasteValues, Transpose:=True
fRow = copyRng.End(xlDown).End(xlDown).Row
Loop While fRow < lRow
End With
End Sub
之前
之后
答案 1 :(得分:0)
如果您的数据是这样布置的:
A B C
+---+---+---------+
1 |...|...|Filename |
2 |...|...|filename1|
3 |...|...|filename2|
4 |...|...|filename3|
5 |...|...|filename4|
6 |...|...|filename5|
7 |...|...| |
8 |...|...|filename1|
9 |...|...|filename2|
10|...|...|filename3|
11|...|...|filename4|
12|...|...|filename5|
13|...|...| |
然后将该公式放在D2
中,然后拖曳填充到H2
上:
=IF(OR($C2="",$C2 = "Filename"),OFFSET($C2,COLUMN(A1),0),"")
您的结果应如下所示:
A B C D E F G H
+---+---+---------+---------+---------+---------+---------+---------+
1 |...|...|Filename | | | | | |
2 |...|...|filename1|filename1|filename2|filename3|filename4|filename5|
3 |...|...|filename2| | | | | |
4 |...|...|filename3| | | | | |
5 |...|...|filename4| | | | | |
6 |...|...|filename5| | | | | |
7 |...|...| | | | | | |
8 |...|...|filename1|filename1|filename2|filename3|filename4|filename5|
9 |...|...|filename2| | | | | |
10|...|...|filename3| | | | | |
11|...|...|filename4| | | | | |
12|...|...|filename5| | | | | |
13|...|...| | | | | | |