2015-10-18 83 views
0

我使用Excel 2013並希望製作一個簡單的重量換算表!excel 2013更新一個單元格,並允許輸入兩個

這是我想什麼來實現的,我想三個單元格C1,C2 & C3

C1用戶可以輸入公斤這個然後填寫C2用石頭和C3與LB的數目的數。

但是我也希望他們能夠在C2和C3中輸入石頭和磅的數量,以及以千克爲單位自動填充C1的數量。

最後,他們也應該能夠輸入磅的重量,例如C3中的28磅,然後將其轉換爲C1中的Kg和C2中的石塊和Lbs。

數學我覺得我可以做,但我怎樣才能使用單元格這樣顯示結果並接受輸入?

回答

2

將以下程序到工作表的代碼模塊:

Private Sub Worksheet_Change(ByVal Target As Range) 
    If Target.Count = 1 Then 
     If Target.Column = 3 Then 
      If Target.Row < 4 Then 
       Application.EnableEvents = False 
       Select Case Target.Row 
        Case 1 
         Cells(2, 3) = Target * 0.157473 '<-- kg to stone 
         Cells(3, 3) = Target * 2.20462 '<-- kg to pounds 
        Case 2 
         Cells(1, 3) = Target * 6.35029 '<-- stone to kg 
         Cells(3, 3) = Target * 14  '<-- stone to pounds 
        Case 3 
         Cells(1, 3) = Target * 0.453592 '<-- pounds to kg 
         Cells(2, 3) = Target * 1/14 '<-- pounds to stone 
       End Select 
      End If 
     End If 
    End If 
    Application.EnableEvents = True 
End Sub 
+0

謝謝,這個工作,給我什麼,我需要建立在它。 – RTFS

+0

不客氣。很高興我能幫上忙。 –

相關問題