EXCEL如何根据输入的一个数字,自动生成这个数字对应的行和列的表格...
发布网友
发布时间:2024-04-09 20:58
我来回答
共1个回答
热心网友
时间:2024-07-24 10:44
同时按Alt和F11进入宏界面,点菜单的插入,模块,粘贴如下代码:
Sub Test()
Dim i As Integer
i = InputBox("请输入表格的行数,会自动生成一方表格", "Hi")
Cells.ClearFormats
Range(Cells(1, 1), Cells(i, i)).Select
Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
Selection.Borders(xlInsideVertical).LineStyle = xlContinuous
Selection.Borders(xlInsideHorizontal).LineStyle = xlContinuous
End Sub
回到Excel,工具,宏,运行此宏,完成。