Sub sa() ' ' sa Macro ' マクロ記録日 : 2002/10/1 ユーザー名 : H.Miyamoto ' ' Dim MEAS(100): Dim MM(4): Dim NN(4): L = 0: GCM = 1 Sheets("和差").Select LA = 5: CO = 1: a = 1 GoSub yakubun LA = 5: CO = 3: a = 2 GoSub yakubun M = NN(1): N = NN(2) GoSub multiple M = MM(1) * LCM / NN(1) - MM(2) * LCM / NN(2) If M < 0 Then M = M * (-1): Range("E5") = "-" Else Range("E5") = "" End If N = LCM GoSub measure Range("F5") = M / GCM Range("F6") = N / GCM Sheets("和差").Select Range("A1") = "差を計算しました。 " + Str(Now()): Range("A1:F1").Select Exit Sub '~~~~~~~~ SUB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ yakubun: If Cells(LA, CO) > Cells(LA + 1, CO) Then M = Cells(LA + 1, CO): N = Cells(LA, CO) Else M = Cells(LA, CO): N = Cells(LA + 1, CO) End If GoSub measure MM(a) = Cells(LA, CO) / GCM NN(a) = Cells(LA + 1, CO) / GCM Return measure: For K = 1 To M If (M Mod K) = 0 Then L = L + 1: MEAS(L) = K Next For K = 1 To L If (N Mod MEAS(K)) = 0 Then GCM = MEAS(K) Next Return multiple: GoSub measure LCM = M * N / GCM Return End Sub