不建议用VBA,而是将签字部分移至页脚,如果一定要这么做,可能要考虑表格重新绘制(当然,下面代码没有考虑重绘,如果人数变化,就会出现问题):
Sub Test()
r = Range("C65536").End(xlUp).Row + 2
Range("F" & r & ":H" & r + 2).Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDouble
.Weight = xlThick
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDouble
.Weight = xlThick
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Weight = xlThick
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDouble
.Weight = xlThick
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 52428
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("F" & r) = "生产经理"
Range("F" & r + 1) = "财务经理"
Range("F" & r + 2) = "销售经理"
Range("H" & r & ":H" & r + 2) = "签字确认"
End Sub
(1)选中整个工作表
(2)执行菜单栏“格式”-“条件格式”,选“公式”,输入公式:=$A1="北京市"
(3)在对话框中点“格式”,设置“图案”-“单元格底纹”为红色,“边框”为某线,颜色为红色。
(4)点“确定”、“确定”即可。
假设你要在F列最后一个单元格的下面空一个单元格,设置为“生产经理”,可以用以下VBA语句:
x = Range("A65536").End(xlUp).Row + 2
Range("F" & x) = "生产经理"
方法大概如此,具体怎么做看你需求。