Excel将边框应用于活动单元格行范围?

我正在尝试通过使用以下内容将范围A的边框应用于活动单元格行上的范围M.

Range("A:" & ActiveCell.Row & "M" & ActiveCell.Row).Borders(xlInsideHorizontal).LineStyle = xlContinuous 

由于某种原因,这是行不通的,请问有人告诉我,我要去哪里工作?

谢谢

你有两个问题。

首先,你的结肠是在错误的地方。 例如:

 Range("A:" & ActiveCell.Row & "M" & ActiveCell.Row).Borders(xlInsideHorizontal).LineStyle = xlContinuous 

应该:

 Range("A" & ActiveCell.Row & ":M" & ActiveCell.Row).Borders(xlInsideHorizontal).LineStyle = xlContinuous 

其次,xlInsideHorizo​​ntal将边框放在范围内,但是您select的是没有内边框的范围。

试想一下,你的活动行是10.你的代码是说:

 Range("A10:M10").Borders(xlInsideHorizontal).LineStyle = xlContinuous 

范围A10到M10没有内部单元格来应用内部边界。