2016-11-04 83 views
0

我想通過使用以下內容將範圍A的邊框應用於活動單元格行上的範圍M.Excel將邊框應用於活動單元格行範圍?

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

由於某種原因,這不起作用,請問誰能告訴我我要去哪裏worng?

謝謝

回答

1

您有2個問題。

首先,你的冒號在錯誤的地方。例如:

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

應該是:

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

其次,xlInsideHorizo​​ntal把邊框的範圍內,但你選擇一個沒有國界內的範圍。

試想一下,你的主動行10你的代碼是說:

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

範圍A10至M10沒有內部細胞應用內部邊框。

相關問題