Tag: 边界

macros(VBA)在Excel中添加边框并合并单元格,如果单元格不为空

我logging了下面的macros: Sub Macro1() Range("E66:F68").Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = […]

Excel VBA – 如何select整个边界表

我很新的Excel VB。 我希望你能帮助我的问题。 我有几个这样的桌子 这些表格可以通过用户插入新行等进行编辑。 我想要突出显示并复制最新的表格(最后一行),并将其粘贴到下一个可用空间,即3行。 我设法做到这一点,但我只能用数据突出显示和复制单元格。 所以在表格中间应该有一个空行,或者空的最后一行有边框,否则不能正确复制,如下所示: 我仍然需要复制包括空行在内的所有内容,但是我缺乏这方面的技能和知识。 我希望你能协助。 以下是我的代码: Sub CopyPaste() LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row FirstColumn = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlNext).Column LastColumn = Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column BelowLastName = Cells.Find("", After:=Cells(LastRow, FirstColumn), SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Row Cells(BelowLastName, FirstColumn).Select 'This selects C5 (refer image) Selection.Offset(-1).Select 'This selects C4 (refer image) Range(Selection, Cells(LastRow, LastColumn)).Select 'This highlights whole table […]

在使用的单元格范围VBA中应用边框

我正在尝试dynamic地在一组使用的单元格周围应用边框 。 列的范围是(B7:E7) 行数总是会变化的 ,所以代码需要是dynamic的。 我的代码如下没有实现这一点: Sub Borders() Application.ScreenUpdating = False Dim lngLstCol As Long, lngLstRow As Long lngLstRow = ActiveSheet.UsedRange.Rows.Count lngLstCol = ActiveSheet.UsedRange.Columns.Count For Each rngCell In Range("B7:B" & lngLstRow) If rngCell.Value > "" Then r = rngCell.row c = rngCell.Column Range(Cells(r, c), Cells(r, lngLstCol)).Select With Selection.Borders .LineStyle = xlContinuous .Weight = xlThin .ColorIndex […]

PHPExcel公式边框厚度问题

当我尝试在单元格周围设置中等边框时,它将无法正确显示(在图片中可以看到)。 在编辑单元格而不改变其值(input单元格编辑并按下回车键)后,显示正确。 我正在使用Excel 2007。 更新前的屏幕 <?php include 'mySQLconnect.php'; /** Error reporting */ error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); date_default_timezone_set('Europe/London'); if (PHP_SAPI == 'cli') die('This example should only be run from a Web Browser'); /** Include PHPExcel */ require_once dirname(__FILE__) . '/PHPExcel_1.8.0/Classes/PHPExcel.php'; // Create new PHPExcel object $objPHPExcel = new PHPExcel(); $objPHPExcel->getActiveSheet(); $objPHPExcel->getActiveSheet()->setTitle('Sheet 1'); $objPHPExcel->getActiveSheet()->setCellValue('B2', '1'); $objPHPExcel->getActiveSheet()->setCellValue('B2', […]

如何改善macroslogging器的代码?

我从macroslogging器使用这个代码,并添加一个for循环。 如果可能的话,如何更好地执行此代码? 我想同时使用2003年和2010年。 Range(Cells(2, 2).Address, Cells(5, 5).Address).Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlDouble .Color = -16777216 .Weight = xlThick End With With Selection.Borders(xlEdgeTop) .LineStyle = xlDouble .Color = -16777216 .Weight = xlThick End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlDouble .Color = -16777216 .Weight = xlThick End With With Selection.Borders(xlEdgeRight) .LineStyle […]

Excel VBA添加边框,如果某些行上的活动单元格

我正在为甘特图电子表格写一些VBA。 我在第5行有3个月的date价值,我可以通过在更新整个工作表的单元格中inputdate来设置开始date。 我有一个单元格的范围为我的图表L6:CZ42。 对于这个范围,如果第5行的单元格是月份的第一个,则该列中的每个单元格将具有灰色虚线的左边框,而右边没有任何内容。 这工作如何我想要的。 问题是,它增加了一个灰色边框的单元格的上方和底部,行7到41是好的,但行6我想要一个黑色的顶部边框和行42我想要一个黑色的底部边框。 我添加了这段代码试图sorting这个问题,但语法错误检查是否在第6行 ' If this is the first row (6) in the range then ' add a black continuous border to the top If Cells(6, i) Then With .Borders(xlEdgeTop) .ColorIndex = 1 .Weight = xlThin .LineStyle = xlContinuos End With End If 这是我的整个代码 Sub Worksheet_Change(ByVal Target As Range) Dim i […]

Excel求解器,初始variables单元值影响求解器

我有以下问题:我需要通过改变另一个单元格的值,这需要一个整数,以最小化单元格。 我的Excel解算器有时可以正常工作,有时候它不能解决问题。 我注意到它取决于初始条件,所以根据初始可变单元值,求解器可能会find一个不是最优的解。 有什么想法呢? 附上你find运行解算器的VBA代码块。 Sub optimizer1() optimizer1 Macro SolverReset 'resetting solver SolverOk SetCell:="$AD$4", MaxMinVal:=2, ValueOf:=0, ByChange:="$Q$4", Engine:= _ 1, EngineDesc:="GRG Nonlinear" 'setting up target and input cell SolverAdd CellRef:="$Q$4", Relation:=4, FormulaText:="integer" 'The value of variable cell must be integer 'SolverAdd CellRef:="$U$4", Relation:=1, FormulaText:="$L$4" 'setting up the range (these are the boundary conditions) 'SolverAdd CellRef:="$U$4", […]

C#检查是否存在单元边框

我正在用C#使用Microsoft.Office.Interop.Excel做一个小项目,我有点卡住了。 我想要做的是创build一个方法,需要一个范围,然后返回true或失败的基础上,如果有一个边界在范围的底部边缘。 private bool BottomEdgeHasBorder(string range) { if (has border at bottom edge of range) return true; else return false; } 我已经search了很多这个问题,但我能find的是有关添加边框的问题。 我只是想检查是否有边界。 我努力了 Excel.Range range = ExcelWorksheet.get_Range(range, Type.Missing); if (range.Borders[Excel.XlBordersIndex.xlEdgeBottom] == Excel.XlLineStyle.xlContinuous) return true; 伟大的任何帮助!

我怎样才能在C#中的Excel范围添加底部边框?

我需要在电子表格的某些行上添加一个底部边框(简单的实线)。 我有我需要定义的范围,但尝试添加边界代码失败了,从注释掉的尝试可以看出: private ApplicationClass _xlApp; private Workbook _xlBook; private Sheets _xlSheets; private Worksheet _xlSheet; . . . private void AddBottomBorder(int rowToBottomBorderize) { var rangeToBottomBorderize = (Range)_xlSheet.Cells[rowToBottomBorderize, TOTALS_COL]; //rangeToBottomBorderize.Borders[_xlApp.XlBordersIndex.xlEdgeBottom] = //rangeToBottomBorderize.Borders[XlBordersIndex.xlEdgeBottom] = 1d; //rangeToBottomBorderize.Borders[_xlSheet. //_xlSheet.Cells[rowToBottomBorderize, TOTALS_COL].Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight = 1d; // someRange.Borders.Item[XlBordersIndex.xlEdgeBottom)] = …what now? } 我需要哪些对象的属性或方法进行分配或调用,以及如何执行?

如果文本存在,Excel底部边框?

此刻我正在创build发票,每张发票上都会有不同数量的文字。 理想情况下,我希望能够input内容,一旦我这样做,它会创build一个沿该行底部的边界,从A到K,如果这是有道理的。 这可能吗? 干杯:)