excel 合并单元格内容

首先我的原始数据是
excel <wbr>合并单元格内容

要把它变成如下的样子。txt格式
excel <wbr>合并单元格内容
我用了以下的vba完成
Sub ds()
Dim i As Integer
Dim j As Integer
Dim m As Integer
j = 2
m = 2
For i = 2 To 3402
If Sheets("Sheet").Cells(i, 1).Value = Sheets("Sheet").Cells(j, 5).Value Then
Sheets("Sheet").Cells(j, 6 + m - 2).Value = Sheets("Sheet").Cells(i, 2).Value
m = m + 1
Else: Sheets("Sheet").Cells(j + 1, 6).Value = Sheets("Sheet").Cells(i, 2).Value
j = j + 1
m = 3
End If
Next i
End Sub

以上用于把相同的id 的 A 放在同一行
第二个是加入逗号的vba,最后结果复制到txt上就可以了
Sub ds1()
Dim i As Integer
Dim j As Integer
j = 2
i = 6
With Sheets("Sheet")
Do While j <= 641
If .Cells(j, i + 1).Value > 0 Then
.Cells(j, 6) = .Cells(j, 6) & "," & .Cells(j, i + 1)
i = i + 1
Else: j = j + 1
i = 6
End If
Loop
End With
End Sub



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值