==========================
Sub 设置行列自适应()
With Excel.ActiveSheet
.Rows.AutoFit
'.Columns.AutoFit
End With
End Sub
==========================
Sub 批量调整行高()
'操作的时候注意选择单元格只能从上到下选择,因为这会影响Activecell的定位
Dim iRow As Integer
Dim i As Integer, r As Integer
iRow = Selection.Rows.Count
r = ActiveCell.Row
'首先判断选择的区域是一个还是多个,仅一个区域的时候执行代码
If Selection.Areas.Count = 1 Then
For i = 1 To iRow
Rows(r + i - 1).RowHeight = 40
Next
End If
End Sub
==========================
Sub 控制行高最小值()
Dim iRow As Integer
Dim i As Integer, r As Integer
iRow = Selection.Rows.Count
r = ActiveCell.Row
If Selection.Areas.Count = 1 Then
For i = 1 To iRow
If Rows(r + i - 1).RowHeight < 31.5 Then Rows(r + i - 1).RowHeight = 31.5
Next
End If
End Sub
==========================
==========================
==========================
==========================
==========================
==========================
Sub 选定区域合并相同内容单元格()
Application.Goto Reference:="Macro1"
Application.DisplayAlerts = False
Set Rng = Selection
With Rng
For i = Rng.Rows.Count To 2 Step -1
If Rng.Cells(i - 1, 1) = Rng.Cells(i, 1) Then
Rng.Range(Cells(i - 1, 1), Cells(i, 1)).Merge
End If
Next
End With
Application.DisplayAlerts = True
End Sub
==========================
==========================
==========================
==========================
==========================
==========================
==========================
==========================