一个EXCEL列转行的问题,高分求解

sukey00 2009-04-28 03:51:30
EXCEL一组数据如下
a 1 3 4 5
b 1 3
c 1 5


需要转换为以下数据格式
a 1
a 3
a 4
a 5
b 1
b 3
c 1
c 5

请问如何转换,谢谢!
...全文
493 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zclzyyh 2009-05-14
  • 打赏
  • 举报
回复
你的问题没有交代清楚,是不是第一行第一格为a,向右单元格分别为1、2、3、……;第二行第一格为b,向右单元格分别为1、2、3、……;
最好有EXCEL附件挂上来。
konma 2009-05-11
  • 打赏
  • 举报
回复
选择性粘贴-转置
readfuture 2009-05-04
  • 打赏
  • 举报
回复
友情帮顶
shenkui1920 2009-05-04
  • 打赏
  • 举报
回复
有点难,帮顶
colepig_hj 2009-05-04
  • 打赏
  • 举报
回复
厉害
flyhua1010 2009-04-29
  • 打赏
  • 举报
回复
学习
zhiyongtu 2009-04-29
  • 打赏
  • 举报
回复
gracexu 强!
gracexu 2009-04-29
  • 打赏
  • 举报
回复

Function LineToColumn(originalRange As Range) As Variant
Dim i, j, n As Long
n = 0
Dim result()
Dim CallerRows, CallerCols As Long
With Application.Caller
CallerRows = .Rows.Count
CallerCols = .Columns.Count
End With

If CallerCols < 2 Then
MsgBox "too little columns"
Exit Function
End If
ReDim result(1 To CallerRows, 1 To CallerCols)

For i = 1 To originalRange.Rows.Count
For j = 2 To originalRange.Columns.Count
If IsEmpty(originalRange.Cells(i, j)) Then
Exit For
End If
n = n + 1
If n > CallerRows Then
GoTo lastline
End If

result(n, 1) = originalRange.Cells(i, 1)
result(n, 2) = originalRange.Cells(i, j)
Next j
Next i
lastline:
LineToColumn = result
End Function

试一下这个吧,选择你要返回结果的一块区域,输入,比如
=LineToColumn(A1:E3),按ctrl+shift+enter 作为数组函数输入,参数是原始数据的区域
sukey00 2009-04-28
  • 打赏
  • 举报
回复
顶一个啊

6,210

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office应用
社区管理员
  • Microsoft Office应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧