If Target.Column = 8 Then //如果點擊的是是第8列
Dim i As Integer // i 爲整型
For i = 1 To 455 //循環語句 從 1到455
Cells(i, 8).Value = Cells(i, 8).Value //單元格(行,列)的值 = 單元格(行,列)的值。此處主要是爲了把字符串格式轉爲數值格式。運行前將此列單元格設置爲數值。
Next
End If
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 1 Then
Dim j As Integer
For j = 3 To 155
If Cells(j, 1).Value = "" Then
Cells(j, 1).Value = Cells(j - 1, 1).Value // 讓後一行單元格等於上一行單元格的值
End If
Next
End If
If Target.Column = 4 Then
Dim i As Integer
For i = 1 To 155
Cells(i, 4).Value = Cells(i, 4).Value
Next
End If
End Sub
此代碼執行結果就是將單元格左上角的三角符號去掉(在設置單元格爲數值不起作用的時候)。
打開代碼編輯器快捷鍵 ALT+F11