過去ログ

???
エクセルのマクロです。
Option Explicit
Sub Macro1()
Dim n As Integer
Dim wa As Integer
Dim j As Integer
Dim jj As Integer
For n = 0 To 15
Cells(1, n + 1).Value = 0
For j = 0 To 15
If j = 0 Then
jj = 1
ElseIf j <= 7 Then
jj = jj + 2
ElseIf j >= 9 Then
jj = jj - 2
End If
Cells(1, n + 1).Value = Cells(1, n + 1).Value + box((n + j) Mod 16) * jj
Next j
Next n
Cells(3, 1).Value = "=MIN(A1:P1)"
For n = 1 To 16
If Cells(1, n).Value = Cells(3, 1).Value Then
Range(retsu(n) & "1").Select
End If
Next n
End Sub
Private Function box(ByVal n As Integer) As Integer
Select Case n
Case 0
box = 2
Case 1
box = 10
Case 2
box = 6
Case 3
box = 4
Case 4
box = 7
Case 5
box = 2
Case 6
box = 4
Case 7
box = 6
Case 8
box = 1
Case 9
box = 9
Case 10
box = 5
Case 11
box = 3
Case 12
box = 7
Case 13
box = 2
Case 14
box = 9
Case Else
box = 7
End Select
End Function
Private Function retsu(ByVal n As Integer) As String
Dim retsu1 As String
retsu1 = ActiveSheet.Cells(1, n).Address(False, False)
retsu = Left(retsu1, Len(retsu1) - 1)
End Function
   11月18日(木) 13:09:07     37044

過去問題一覧へ戻る