展开全部
'自定义公式-按ALT+F11-插入-模块-粘贴代码-将表格另存为启用宏的格式(xlsm)
Function 横排转竖排(a As Range, b As String, f As String)
For i = 1 To a.Rows.Count
For j = 2 To a.Columns.Count
If a.Cells(i, j) = "" Then Exit For
d = d & "|" & a.Cells(i, 1)
e = e & "|" & a.Cells(i, j)
Next
If a.Cells(i, 1) = "" Then Exit For
Next
g = Split(d, "|")
h = Split(e, "|")
If f = 1 Then
横排转竖排 = g(b)
Else
横排转竖排 = h(b)
End If
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
公式需要建立一个辅助列,然后用数组公式,
直接用vba
Sub 转换()
Columns("H") = ""
Dim I, X
For I = 1 To Range("a65536").End(xlUp).Row
arr = Range(Cells(I, "B"), Cells(I, "E"))
X = WorksheetFunction.CountA(Range(Cells(I, "A"), Cells(I, "E")))
Y = Range("h65536").End(xlUp).Row
Range(Cells(Y + 1, "H"), Cells(Y + X - 1, "H")) = Cells(I, "A")
Cells(Y + 1, "i").Resize(4, 1) = Application.Transpose(arr)
Next
End Sub
直接用vba
Sub 转换()
Columns("H") = ""
Dim I, X
For I = 1 To Range("a65536").End(xlUp).Row
arr = Range(Cells(I, "B"), Cells(I, "E"))
X = WorksheetFunction.CountA(Range(Cells(I, "A"), Cells(I, "E")))
Y = Range("h65536").End(xlUp).Row
Range(Cells(Y + 1, "H"), Cells(Y + X - 1, "H")) = Cells(I, "A")
Cells(Y + 1, "i").Resize(4, 1) = Application.Transpose(arr)
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
H1:
=INDEX(A:A,SMALL(IF($B$1:$G$3<>"",ROW($1:$3),4^8),ROW(A1)))&""
ctrl+shift+回车,下拉
I1:
=IF(H1="","",VLOOKUP(H1,A:G,COUNTIF(H$1:H1,H1)+1,))
下拉
=INDEX(A:A,SMALL(IF($B$1:$G$3<>"",ROW($1:$3),4^8),ROW(A1)))&""
ctrl+shift+回车,下拉
I1:
=IF(H1="","",VLOOKUP(H1,A:G,COUNTIF(H$1:H1,H1)+1,))
下拉
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询