二、如果你堅持要在輸入數(shù)據(jù)的單元格中直接轉(zhuǎn)換中文大寫,只好用VBA程序代碼了,只是比較煩。 代碼如下: Private Sub Worksheet_Change(ByVal aa As Range) On Error GoTo error If aa.Column = 1 Then Select Case aa Case Is > 0 aa = Replace(Application.Text(aa, "[DBnum2]"), ".", "點") Case Is < 0 aa = "負" & Replace(Application.Text(Abs(aa), "[DBnum2]"), ".", "點") Case Is = 0 aa = "" End Select End If error: Exit Sub End Sub
3。如果不考慮負數(shù)、零等情況的話,代碼可以簡化如下: Private Sub Worksheet_Change(ByVal aa As Range) If aa.Column = 1 Then aa = Replace(Application.Text(aa, "[DBnum2]"), ".", "點") End If
End Sub 采用簡化代碼的情況下,輸入的數(shù)字必須 >0 ,如果輸入 <=0 的數(shù)字會有意想不到結(jié)果。因為代碼中沒有處理0和<0數(shù)字的語句。請涼解。