|
楼主 |
发表于 2022-11-16 16:22
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
谢谢老哥,这个问题已经明白了,另外有个函数卡了我一个下午了,不知可否指点一二
Sub 自动填充抬头()
'
Rows("6:6").Select
Selection.AutoFilter
ActiveSheet.Range("$A$6:$R$1312").AutoFilter Field:=10, Criteria1:="=小计", _
Operator:=xlOr, Criteria2:="="
Set Rng = [a1]
Set Rng = Union([a:a].SpecialCells(12), Rng)
Rows("Rng(1):Rng(1)").Select'运行到这里的时候会报错,我想实现的效果是选中筛选后不含表头(用于筛选的这行)的第一行
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Rows("6:6").Select
Selection.AutoFilter
i = Range("a10000").End(xlUp).Row
Range("A7:H" & i).Select
ActiveWindow.SmallScroll Down:=12
Selection.Replace What:="", Replacement:="A", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="A", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "=R[-1]C"
ActiveWindow.SmallScroll Down:=18
End Sub
|
|