Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents Seiji Mori Presents

数値

小数点位置
Selection.NumberFormatLocal = "0"
 
数値かどうか
If IsNumeric(TanP) = False Then
End If
 
整数でない
If HenInMax - Fix(HenInMax) <> 0 Then
 
符号
Hugou(I) = Sgn(Cells(3, 2 + I))
  ’Sgn(number)
  引数 number は必ず指定します。引数 number には、任意の数式を指定します。
  number の値 戻り値
  number > 0  1
  number = 0  0
  number < 0  -1
 
自然対数
AICValue = DataNum * Log(1 - Cells(5, 2).Value) + 2 * 2
  倍精度浮動小数点数型 (Double) の自然対数を返す数値演算関数です。
  Log(number)
  自然対数とは、定数 e を底とする対数です。定数 e の値は約 2.718282 です。
  任意の数値 x の n を底とする対数は、次に示すように x の自然対数を n の自然対数で割ることによって得ら  れます。
    Logn(x) = Log(x) / Log(n)
  次の Function プロシージャは、引数に指定した数値の常用対数 (10 を底とする対数) を計算します。
    Static Function Log10(X)
      Log10 = Log(X) / Log(10#)
    End Function
 
整数かどうか
’整数でない
If Avg_Sec Mod Data_Sec <> 0 Then
 
わり算の余り
number1 Mod number2
数式 number1 を数式 number2 で除算し、その余りを演算結果 result として返します。このとき浮動小数点数は整数に丸められます。
 
整数部分を得る
MyNumber = Int(99.8) ' 99 を返します
MyNumber = Int(-99.2) ' -100 を返します。
MyNumber = Fix(-99.2) ' -99 を返します。
 
平方根
Sqr(number)
数式の平方根を倍精度浮動小数点数型 (Double) の値で返す数値演算関数です。
Sqr(3.1415926)

 
Exp(number)
指数関数 (e を底とする数式のべき乗) を計算する数値演算関数です。
f = Exp(-(X ^ 2))
 
絶対値
If Abs(Cells(3, i).Value) < CorrelLow Then

 
文字列に含まれている数値を返します。
Dim MyValue
MyValue = Val("2457") ' 2457 を返します。
MyValue = Val(" 2 45 7") ' 2457 を返します。
MyValue = Val("24 and 57") ' 24 を返します

 
乱数
Sub 乱数ためし()
 
  Dim myRnd(1 To 10, 1 To 3)
  Dim i As Integer
   
  Randomize '初期化
  
  For i = 1 To 10
    myRnd(i, 1) = Int(Rnd * 10)   '1桁の乱数
    myRnd(i, 2) = Int(Rnd * 100)  '2桁
    myRnd(i, 3) = Int(Rnd * 1000) '3桁
  Next i
  'Rnd関数:0以上、1未満の数
  'Int関数:小数点以下の切り捨て
   
  Cells(1, 1).Resize(10, 3).Value = myRnd
     
End Sub
 

**** 基準値以上または以下の数値を赤色に変える ****
Sub 数値以下以上()
  Dim myRange As Range
  Dim FirstRow As Long
  Dim FirstCol As Integer
  Dim LastRow As Long
  Dim LastCol As Integer
  Dim Kijun As Single
  Dim IjyouIka As Integer
  Dim i As Integer
  Dim j As Integer
 
  Set myRange = Application.InputBox("セル範囲を選択して下さい", , Selection.Address, , , , , 8)
 
  FirstRow = myRange.Row
  FirstCol = myRange.Column
  LastRow = myRange.Row + myRange.Rows.Count - 1
  LastCol = myRange.Column + myRange.Columns.Count - 1
 
  Kijun = Application.InputBox("基準値を記入して下さい", , , , , , , 1)
  IjyouIka = Application.InputBox("以上なら数値の0を、以下なら数値の1を記入して下さい", , , , , , , 1)
 
  If IjyouIka = 0 Then
    For i = FirstCol To LastCol
      For j = FirstRow To LastRow
        If IsNumeric(Cells(j, i).Value) Then
          If Cells(j, i).Value > Kijun Then
            Cells(j, i).Font.ColorIndex = 3
          End If
        End If
      Next j
    Next i
  ElseIf IjyouIka = 1 Then
    For i = FirstCol To LastCol
      For j = FirstRow To LastRow
        If IsNumeric(Cells(j, i).Value) Then
          If Cells(j, i).Value < Kijun Then
            Cells(j, i).Font.ColorIndex = 3
          End If
        End If
      Next j
   Next i
  End If
 
End Sub