我想知道如何在不放入包含“工作表”或“工作表”的代码的情况下应用外部边框(范围A1:M4)。 例如
With Worksheets("Sheet1").Range("B8:I10").BorderAround
[INDENT].LineStyle = xlContinuous[/INDENT]
[INDENT].Weight = xlThick[/INDENT]
End With
OR
With Sheet1.Range("B8:I10").Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
End With
这是因为Sheet尚未设置(关于我的用户界面格式如何)以及我正在使用VBA模块
答案 0 :(得分:0)
您可以尝试在变量中分配新创建的工作表。这将返回工作表名称。
Option Explicit
Dim MainWorkBook As Workbook
Dim MainWorksheet As Worksheet
Sub ReturnWorkSheetName()
Set MainWorkBook = ActiveWorkbook
Set MainWorksheet = MainWorkBook.ActiveSheet
MsgBox MainWorksheet.Name
End Sub
答案 1 :(得分:0)
FormatControlCell.Borders[XlBordersIndex.xlEdgeLeft].LineStyle = XlLineStyle.xlContinuous;
FormatControlCell.Borders[XlBordersIndex.xlEdgeRight].LineStyle = XlLineStyle.xlContinuous;
FormatControlCell.Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous;
FormatControlCell.Borders[XlBordersIndex.xlEdgeTop].LineStyle = XlLineStyle.xlContinuous;
FormatControlCell.Borders.Weight = XlBorderWeight.xlThin;
FormatControlCell.Borders[XlBordersIndex.xlDiagonalDown].LineStyle = XlLineStyle.xlLineStyleNone;
FormatControlCell.Borders[XlBordersIndex.xlDiagonalUp].LineStyle = XlLineStyle.xlLineStyleNone;
FormatControlCell.Borders[XlBordersIndex.xlInsideHorizontal].LineStyle = XlLineStyle.xlLineStyleNone;
FormatControlCell.Borders[XlBordersIndex.xlInsideVertical].LineStyle = XlLineStyle.xlLineStyleNone;