这是按5列写的公式,不知道你的行号列号,公式结果有可能不对,需要你自己改一下。
=INDEX(A:A,ROUNDUP(ROW()/5,0))
=INDIRECT("R"&ROUNDUP(ROW()/5,0)&"C"&MOD(ROW(A5),5)+2,FALSE)
答:可以利用VBA一步完成,代码如下:
Sub Demo()
Dim CurSht As Worksheet
Dim DesRng As Range
Dim LastRow As Long, lastCol As Long
Dim i As Long, j As Long
Set CurSht = ActiveSheet
With Sheets.Add
Set DesRng = .Range("A1")
End With
With CurSht
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow
If Not IsEmpty(.Cells(i, "A")) Then
lastCol = .Cells(i, Columns.Count).End(xlToLeft).Column
For j = 1 To lastCol - 1
If Not IsEmpty(.Cells(i, j + 1)) Then
DesRng = .Cells(i, "A")
DesRng.Offset(0, 1) = .Cells(i, j + 1)
Set DesRng = DesRng.Offset(1, 0)
End If
Next
End If
Next
End With
MsgBox "转换完成", vbInformation, "提示"
End Sub
运行方法:
按ALT+F11组合键,打开VB窗口,执行"插入"-"模块",复制下面代码进去,按F5运行程序即得到结果。
有文件才方便处理,把问题作为内容(邮件主题一定要包含“excel”,本人以此为依据辨别非垃圾邮件,以免误删),excel样表文件(把现状和目标效果表示出来,并说明如何从现状到的目标效果)作为附件发来看下 yqch134@163.com
请问各位老师,类似上面案例的多行转置为一列,同时匹配其他的数据公式应该如何设置?