Option Explicit Private MODE As Integer Sub sample() Dim s As String s = "12.25" MODE = 1: MsgBox (RoundEx(s, 1)) MODE = 2: MsgBox (RoundEx(s, 1)) MODE = 3: MsgBox (RoundEx(s, 1)) MODE = 4: MsgBox (RoundEx(s, 1)) s = "12.35" MODE = 1: MsgBox (RoundEx(s, 1)) MODE = 2: MsgBox (RoundEx(s, 1)) MODE = 3: MsgBox (RoundEx(s, 1)) MODE = 4: MsgBox (RoundEx(s, 1)) End Sub Function RoundEx(ByVal strNumber As String, ByVal intDigit As Integer) As String If Not IsNumeric(strNumber) Then RoundEx = "" Exit Function End If Select Case MODE Case 1 '切り下げ RoundEx = WorksheetFunction.RoundDown(strNumber, intDigit) Case 2 '切り上げ RoundEx = WorksheetFunction.RoundUp(strNumber, intDigit) Case 3 '四捨五入 RoundEx = WorksheetFunction.Round(strNumber, intDigit) Case 4 'JIS丸め RoundEx = Round(strNumber, intDigit) Case Else RoundEx = strNumber End Select If intDigit > 0 Then RoundEx = Format(RoundEx, "0." & String(intDigit, "0")) End If End Function