2010年6月11日星期五

儲存格設計清單

Private Sub Worksheet_Change(ByVal Target As Range)

x = Left(Target.Address, 2)
If x = "$A" Then
Select Case Target.Value
Case 2
Target.Value = "台北"
Case 3
Target.Value = "桃園"
Case 4
Target.Value = "台中"
Case 5
Target.Value = "嘉義"
Case 6
Target.Value = "台東"
Case 7
Target.Value = "高雄"

End Select


End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

x = Left(Target.Address, 2)
If x = "$C" Then
Select Case Target.Value
Case 1
Target.Value = ActiveCell.Offset(0, -1).Value + ActiveCell.Offset(0, -2).Value

Case 2
Target.Value = (ActiveCell.Offset(0, -1).Value + ActiveCell.Offset(0, -2).Value) / 2
Case 3
Target.Value = ActiveCell.Offset(0, -1).Value - ActiveCell.Offset(0, -2).Value


End Select


End If


End Sub




Private Sub Worksheet_Activate()
Range("b6").FormulaR1C1 = "=SUM(R[-4]C:R[-1]C)"
X = ActiveCell.Value2

ActiveCell.Value = X




End Sub

Private Sub OK_Click() ' 表單元件


ActiveCell.Offset(0, 0).Value = num1.Value
ActiveCell.Offset(0, 1).Value = num2.Value
ActiveCell.Offset(0, 2).Value = num3.Value
ActiveCell.Offset(0, 3).Value = num4.Value
ActiveCell.Offset(1, 0).Select
num1.Value = Empty
num2.Value = Empty
num3.Value = Empty
num4.Value = Empty
num1.SetFocus

End Sub

0 评论:

 
妹咕數位學園歡迎網友們來信指教 妹咕信箱