(1)单元格的显示及隐藏
代码
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "显示OD Entery" Then
CommandButton1.Caption = "不显示OD Entery"
Columns(5).Hidden = False '隐藏列
Columns(8).Hidden = False
Columns(10).Hidden = False
Columns(12).Hidden = False
Else
CommandButton1.Caption = "显示OD Entery"
Columns(5).Hidden = True '显示列
Columns(8).Hidden = True
Columns(10).Hidden = True
Columns(12).Hidden = True
End If
End Sub
(2) 查找某一列中指定数值出现的位置
代码
'找出指定列中第一个名字为"Transmit"的单元格所在的行数
Function FindFirstRow(col) As Integer
Dim i
For i = 1 To Sheet1.UsedRange.Rows.Count '使用的最大行数
If Sheet1.Cells(i, col) = "Transmit" Then
Exit For
End If
Next i
FindFirstRow = i
End Function
(3)选择某一个单元格
Private Sub CommandButton9_Click()
Sheet1.Range("A4").Select
End Sub