|
关于区域设置问题
Sub test()
Dim rng As Range
On Error Resume Next
Set rng = Application.InputBox("请选择", "提示", , , , , Type:=8)
If rng Is Nothing Then Exit Sub
'假如我选择的是B5,当前工作表中,最后一个最非空单元格地址是U60
'那么就将B5:U60这个区域自动列宽,字体排列水平居中,字号12号。
'请朋友们把我完善下这个代码,最后一个非空单元格地址不确定(用代码来判断)。
End Sub
谢谢大家了!
- Sub Macro1()
- Dim rng As Range
- On Error Resume Next
- Set rng = Application.InputBox("请选择", "提示", , , , , Type:=8)
- If rng Is Nothing Then Exit Sub
- Set c1 = Cells.Find("*", , , , xlByRows, xlPrevious)
- Set c2 = Cells.Find("*", , , , xlByColumns, xlPrevious)
- With Range(rng, Cells(c1.Row, c2.Column))
- .Font.Size = 12
- .HorizontalAlignment = xlCenter
- .Columns.AutoFit
- End With
- End Sub
复制代码
|
|