Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
合并单元格vba excel_Excel_Vba_Merge_Cell_Rows - Fatal编程技术网

合并单元格vba excel

合并单元格vba excel,excel,vba,merge,cell,rows,Excel,Vba,Merge,Cell,Rows,请告诉我的朋友我想合并最后一列的单元格 lastColumn = Worksheets("sheet1").Cells(1, Columns.Count).End(xlToLeft).Column 我使用此代码查找最后一列 lastColumn = Worksheets("sheet1").Cells(1, Columns.Count).End(xlToLeft).Column 这是为了找到更多的行 nbrows = Worksheets("

请告诉我的朋友我想合并最后一列的单元格

lastColumn = Worksheets("sheet1").Cells(1, Columns.Count).End(xlToLeft).Column
我使用此代码查找最后一列

lastColumn = Worksheets("sheet1").Cells(1, Columns.Count).End(xlToLeft).Column
这是为了找到更多的行

nbrows = Worksheets("sheet1").Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
我找到了解决办法

Worksheets("sheet1").Activate
Range(Cells(1, lastColumn), Cells(nbrows, lastColumn)).MergeCells = True

尝试录制宏,然后查看它生成的代码。