一些可能以后会用到的事件响应片段。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
' '所选中区域的第一个单元格,所在行列,进行操作
' Rows(Target.Row).Interior.ColorIndex = 20
' Columns(Target.Column).Interior.ColorIndex = 20
' '所选中的区域,进行操作
' Target.Cells.Interior.ColorIndex = 20
End Sub
Sub 文本框1_Click()
Dim myRange As Range
Set myRange = ActiveSheet.UsedRange
myRange.ClearFormats
With myRange
.RowHeight = Application.CentimetersToPoints(1)
.ColumnWidth = Application.CentimetersToPoints(1)
.VerticalAlignment = xlCenter 'xlRight xlLeft xlDistributed xlGeneral
.HorizontalAlignment = xlCenter 'xlRight xlLeft xlDistributed xlGeneral
End With
' With myRange.Rows
' .VerticalAlignment = xlCenter
' .HorizontalAlignment = xlCenter
' '.NumberFormat = "###.00"
' End With
' '根据行列内容,自动调整宽高
' With myRange.Columns
' .AutoFit
' End With
'
' With myRange.Rows
' .AutoFit
' End With
End Sub