| 
    
     |  | 以前に星取表のようなソフトを作る際に、質問させていただいたものです。 あれから、色々と改良を重ねるにつれ、分からないことが生じました。
 どうぞ、ご教授ください。
 
 1行目と2列目に同じメンバーリストが書かれています。順不同です。
 
 1)4列目に日付が入力されます。
 2)(3、6)以降のセルを選択した状態でこのボタンが押されます。
 3)そのとき、2行目と3列目に出力します。(入っている値より大きければ)
 4)また、A対Bをした際、B対Aに--------を出力します。
 
 このようなプログラムを書いたのですが、
 →の時点で、「オブジェクトが必要です。」となるんです。
 なぜでしょうか。
 
 Private Sub CommandButton52_Click()
 
 Dim i As Long
 Dim C As Long
 Dim R As Long
 
 With Worksheets("Sheet1")
 →    If Intersect(Target, Range(.Cells(3, 6), .Cells(3, 53))) Is Nothing Then Exit Sub
 If Target.Count > 1 Then Exit Sub
 .Cells(Target.Row, Target.Column).Value = .Cells(Target.Row, 4).Value
 .Cells(Target.Row, Target.Column).Font.ColorIndex = .Cells(Target.Row, 4).Font.ColorIndex
 If .Cells(Target.Row, Target.Column).Value > .Cells(2, Target.Column).Value Then
 .Cells(2, Target.Column).Value = .Cells(Target.Row, Target.Column).Value
 .Cells(2, Target.Column).Font.ColorIndex = .Cells(Target.Row, Target.Column).Font.ColorIndex
 End If
 If .Cells(Target.Row, Target.Column).Value > .Cells(Target.Row, 3).Value Then
 .Cells(Target.Row, 3).Value = .Cells(Target.Row, Target.Column).Value
 .Cells(Target.Row, 3).Font.ColorIndex = .Cells(Target.Row, Target.Column).Font.ColorIndex
 End If
 
 For i = 6 To 53
 If .Cells(Target.Row, 2).Value = .Cells(1, i).Value Then
 C = i
 End If
 Next
 For i = 3 To 50
 If .Cells(1, Target.Column).Value = .Cells(i, 2).Value Then
 R = i
 End If
 Next
 If .Cells(R, C).Value = "" Then
 .Cells(R, C).Value = "'--------"
 .Cells(R, C).Font.ColorIndex = 1
 End If
 End With
 
 End Sub
 
 
 |  |