VBA编写单元格数字合并
答案:2 悬赏:50 手机版
解决时间 2021-04-02 03:53
- 提问者网友:你给我的爱
- 2021-04-01 08:21
VBA编写单元格数字合并
最佳答案
- 五星知识达人网友:青灯有味
- 2021-04-01 08:29
Sub 合并数()
Dim I%, K%
For I = 1 To Range("A65536").End(xlUp).Row * 3
n = Int((I - 1) / 3) + 1
Cells(I, "c") = Cells(n, "a")
Next
For K = 1 To Range("A65536").End(xlUp).Row * 3
M = ((K - 1) Mod 3) + 1
Cells(K, "c") = Cells(K, "c") & Cells(M, "B")
Next
End Sub
试下追问B列不止3行,有几百行,怎么改?追答B列假设有100行,就将
M = ((K - 1) Mod 3) + 1
3修改为 100
试下追问能否自动识别B列的行数,有多少行,它自动合并多少行。追答不知道是不是找一个意思?
Sub 合并数()
Dim I%, K%
x = Range("b65536").End(xlUp).Row
y = Range("a65536").End(xlUp).Row * x
For I = 1 To y
n = Int((I - 1) / x) + 1
Cells(I, "c") = Cells(n, "a")
Next
For K = 1 To Range("A65536").End(xlUp).Row * x
M = ((K - 1) Mod x) + 1
Cells(K, "c") = Cells(K, "c") & Cells(M, "B")
Next
End Sub
Dim I%, K%
For I = 1 To Range("A65536").End(xlUp).Row * 3
n = Int((I - 1) / 3) + 1
Cells(I, "c") = Cells(n, "a")
Next
For K = 1 To Range("A65536").End(xlUp).Row * 3
M = ((K - 1) Mod 3) + 1
Cells(K, "c") = Cells(K, "c") & Cells(M, "B")
Next
End Sub
试下追问B列不止3行,有几百行,怎么改?追答B列假设有100行,就将
M = ((K - 1) Mod 3) + 1
3修改为 100
试下追问能否自动识别B列的行数,有多少行,它自动合并多少行。追答不知道是不是找一个意思?
Sub 合并数()
Dim I%, K%
x = Range("b65536").End(xlUp).Row
y = Range("a65536").End(xlUp).Row * x
For I = 1 To y
n = Int((I - 1) / x) + 1
Cells(I, "c") = Cells(n, "a")
Next
For K = 1 To Range("A65536").End(xlUp).Row * x
M = ((K - 1) Mod x) + 1
Cells(K, "c") = Cells(K, "c") & Cells(M, "B")
Next
End Sub
全部回答
- 1楼网友:想偏头吻你
- 2021-04-01 09:20
这个要双重for循环才可以搞定
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯