Excel VBA边框

我正在寻找添加一个边界到一系列的单元格,正在select一个循环和嵌套的If语句,我在Excel中的VBA。 事情是,我知道的唯一方法是在代码中添加一个下划线语句,但我的老师要我做一个底部边界。 事情是,在尝试了一个在StackOverflow中提到的技巧之后,我似乎无法弄清楚如何让它工作。 有人可以帮忙吗?

Sub InputTitle() 'Subrutine's title is off from the actual task being performed. 'Excel asks user for a title to be input below. Dim strTitle As String strTitle = InputBox("Please enter a title") ActiveWorkbook.Sheets(1).Range("A1") = strTitle & " Library Budget" Range("B4").Select 'Excel goes through the cells, searching for the value 'Net Budget'. 'If Excel finds the value as Total, it will add a bottom border to 'the subsiquent cells, before continuing the loop. Do Until ActiveCell.Value = "Net Budget:" ActiveCell.Offset(1, 0).Range("A1").Select If ActiveCell.Value = "Total:" Then ActiveCell.Offset(-1, 1).Range("A1:D1").Select <<--Selection.Border (xlEdgeBottom)-->> ActiveCell.Offset(1, -1).Range("A1").Select End If Loop End Sub 

我知道有一行代码有“<< – – >>”。 这就是为了识别我所要做的事情。 每次运行代码时,系统都会在该行发生故障,告诉我“对象不支持此属性或方法”。 有人可以解释我做错了什么? 我觉得这是过于基本的,这是我看起来更像一个白痴比任何其他…

<<--Selection.Border (xlEdgeBottom)-->>replace为Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous

simoco说的是真的:如果你录制一个macros,你可以看看代码,看看它在做什么。