2022-08-02 07:00来源:m.sf1369.com作者:宇宇
VBA代码如下(保证第一列(A列)为要合并的数据):
Sub imS()
For Ron = Range(A55445).End(xlUp).Row To 2 Step -1
If Cells(Ron, 1).Value = Cells(Ron - 1, 1).Value Then
Range(A & Ron - 1 & :A & Ron).Merge
End If
Next
End Sub
1
2
3
4
5
6
7
Sub Macro1()
dim years as string
years =2000
Rows(1:1).Select
Selection.AutoFilter
ActiveSheet.cells.AutoFilter Field:=4, Criteria1:=years
End Sub
以上代码定于years 变量,可根据设置年份
然后选择第一行,生成高级筛选,筛选条件是第四列,筛选内容是变量years