在Excel中用VBA编写宏查找一个排列组合
在一表中有许多列,假设A1列为主键:1232415123231要筛选A1列中行排列为:123的所以行并显示(新表或原表中显示都可以)结果如:1....2....3.......
在一表中有许多列,假设A1列为主键:
1
2
3
2
4
1
5
1
2
3
2
3
1
要筛选A1列中行排列为:
1
2
3
的所以行并显示(新表或原表中显示都可以)
结果如:
1....
2....
3....
1....
2....
3.... 展开
1
2
3
2
4
1
5
1
2
3
2
3
1
要筛选A1列中行排列为:
1
2
3
的所以行并显示(新表或原表中显示都可以)
结果如:
1....
2....
3....
1....
2....
3.... 展开
2个回答
展开全部
x = 1 'sheet1的坐标
n = 1 '排序值
y = 1 'sheet2的坐标
Sheet1.Activate
Do While Not Sheet1.Cells(x, 1) = ""
Do While Cells(x, 1) <> n
x = x + 1
Loop
Sheet2.Cells(y, 1) = Sheet1.Cells(x, 1)
y = y + 1
If n = 3 Then n = 1 Else n = n + 1:
x = x + 1
Loop
n = 1 '排序值
y = 1 'sheet2的坐标
Sheet1.Activate
Do While Not Sheet1.Cells(x, 1) = ""
Do While Cells(x, 1) <> n
x = x + 1
Loop
Sheet2.Cells(y, 1) = Sheet1.Cells(x, 1)
y = y + 1
If n = 3 Then n = 1 Else n = n + 1:
x = x + 1
Loop
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询