我想单击一个单元格并运行一个宏以创建边框,如果单元格没有它,并且单元格具有边框则会删除边框。但是当细胞合并时我无法做到。单击合并单元格VBA时如何运行宏
此代码只工作了正常细胞,如果我合并的L11和L12不能运行:
If Not Intersect(Target, Range("L11")) Is Nothing Then
If ActiveSheet.Range("L11").Borders(xlEdgeBottom).LineStyle <> xlLineStyleNone And ActiveSheet.Range("L11").Borders(xlEdgeTop).LineStyle <> xlLineStyleNone Then
'if has border erase it.
ActiveSheet.Range("L11").Borders.LineStyle = xlNone
Else
'if doesn't have border create it.
ActiveSheet.Range("L11").Borders.LineStyle = xlContinuous
End If
我尝试使用相同的代码,并更改范围,但它并不适用于检测工作的时候单击并为合并单元格创建边框。
If Intersect(Target, Range("$M$11:$N$11")) Is Nothing Then
有人可以请我给我解决这个问题。 谢谢。
感谢您answer.its工作,上创建边界合并单元格,但是,如何为此代码创建条件仅适用于特定单元格,如L11和L12(我合并L11和L12)。 –
啊! - 好。请参阅编辑。 – ainwood