excel多列转行
答案:2 悬赏:60 手机版
解决时间 2021-11-24 12:33
- 提问者网友:别再叽里呱啦
- 2021-11-23 11:42
excel多列转行
最佳答案
- 五星知识达人网友:轻熟杀无赦
- 2021-11-23 12:28
用VBA来做吧:
假设原表为Sheet1,目标为Sheet2。
Sub Test()
ljh = ""
n = 1
For i = 2 To Sheet1.Range("A65536").End(xlUp).Row
If Sheet1.Cells(i, "A") <> "" Then
ljh = Cells(i, "A")
c = 1
n = n + 1
Else
c = c + 1
End If
If Sheet2.Cells(1, c * 2) = "" Then Sheet2.Cells(1, c * 2) = "工序"
If Sheet2.Cells(1, c * 2 + 1) = "" Then Sheet2.Cells(1, c * 2 + 1) = "时间"
If Sheet2.Cells(n, 1) = "" Then Sheet2.Cells(n, 1) = ljh
Sheet2.Cells(n, c * 2) = Sheet1.Cells(i, "B")
Sheet2.Cells(n, c * 2 + 1) = Sheet1.Cells(i, "C")
Next
End Sub
假设原表为Sheet1,目标为Sheet2。
Sub Test()
ljh = ""
n = 1
For i = 2 To Sheet1.Range("A65536").End(xlUp).Row
If Sheet1.Cells(i, "A") <> "" Then
ljh = Cells(i, "A")
c = 1
n = n + 1
Else
c = c + 1
End If
If Sheet2.Cells(1, c * 2) = "" Then Sheet2.Cells(1, c * 2) = "工序"
If Sheet2.Cells(1, c * 2 + 1) = "" Then Sheet2.Cells(1, c * 2 + 1) = "时间"
If Sheet2.Cells(n, 1) = "" Then Sheet2.Cells(n, 1) = ljh
Sheet2.Cells(n, c * 2) = Sheet1.Cells(i, "B")
Sheet2.Cells(n, c * 2 + 1) = Sheet1.Cells(i, "C")
Next
End Sub
全部回答
- 1楼网友:我住北渡口
- 2021-11-23 13:08
如果语文的分数在 B2,数学C2,英语 D2,那么 E2单元格内输入 =SUM(B2:D2)就可以求出三门功课 这一学生的 总分,然后下拉,可以求出下面同学的总分追问您给的这个算法与我提问的问题有关系么?这个公式我也会啊
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯