Home > エクセル無料ダウンロード > 足し算テスト(1桁)自動作成ソフト

実行画面

1桁の足し算のテストを自動で作成します。数値は乱数を使っているので毎回違ったテストが作成できます。又、1枚に同じ問題がないようにチェックを行います。

使い方
  1. 問題作成シートの[作成開始]ボタンをクリックします。
  2. 自動的に問題fが作成され、テスト用紙シートに変われば完成です。
問題作成シートの[作成開始]ボタンをクリック

完成した1桁の足し算テスト
完成した1桁の足し算テスト

実行の流れ

乱数の取得は Randomize と RND を使用しています。
  1. 前回の問題の数値を ClearContents で消去します。
  2. Randomize で乱数を初期化します。
  3. 20回ループします。
  4. 乱数で2つの値を作成しセルに入力します。
  5. 上から順に同じ数値がこれまで作成した問題にないかチェックします。
  6. 同じ問題があればループの回数カウントをせずにループします。
  7. 同じ問題がなければループの回数カウントを+1しループします。
  8. 20問できればテスト用紙シートに移動します。

エクセルVBAコード

Option Explicit

Private lrow As Long

Private Function mondaicheck(lr As Long) As Boolean
    Dim m1 As Long
    Dim m2 As Long
    Dim i As Long
    
    mondaicheck = True
    If lr = lrow Then
        Exit Function
    End If
    m1 = Cells(lr, 3)
    m2 = Cells(lr, 4)
    
    For i = 0 To lr - lrow - 1
        If m1 = Cells(lrow + i, 3) And m2 = Cells(lrow + i, 4) Then
            mondaicheck = False
            Exit For
        End If
    Next
End Function

Private Sub CommandButton1_Click()
    Dim lcoun As Long
    Dim i As Long
    
    lcoun = 0
    lrow = 9
    Range(Cells(lrow + 1, 2), Cells(lrow + 21, 4)).ClearContents
    Randomize
    Do While lcoun < 20
        Cells(lrow + lcoun, 3) = Int((9 - 1 + 1) * Rnd + 1)
        Cells(lrow + lcoun, 4) = Int((9 - 1 + 1) * Rnd + 1)
        If mondaicheck(lrow + lcoun) = True Then
            Cells(lrow + lcoun, 2) = lcoun + 1
            If lcoun < 10 Then
                Sheets("テスト用紙").Cells(6 + lcoun, 4) = Cells(lrow + lcoun, 3)
                Sheets("テスト用紙").Cells(6 + lcoun, 8) = Cells(lrow + lcoun, 4)
            Else
                Sheets("テスト用紙").Cells(6 + lcoun - 10, 18) = Cells(lrow + lcoun, 3)
                Sheets("テスト用紙").Cells(6 + lcoun - 10, 22) = Cells(lrow + lcoun, 4)
            End If
            lcoun = lcoun + 1
        End If
    Loop
    
    Sheets("テスト用紙").Select
End Sub

エクセルソフト無料ダウンロード

足し算テスト(1桁)自動作成ソフト - 無料ダウンロード







Copyright (C) excel.usefulhp.com All rights reserved.