|
妻・子供は就寝中で、梅酒片手に至福の時間をすごしながら作ってみました。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Long
Dim i As Long
If Target.Column >= 3 Then Exit Sub
Application.EnableEvents = False
With Range("C" & Target.Row)
If Not IsNumeric(.Offset(, -2).Value) Then
.Replace What:="◆", Replacement:=""
Exit Sub
End If
If Not IsNumeric(.Offset(, -1).Value) Then
.Replace What:="●", Replacement:=""
Exit Sub
End If
.Value = ""
For i = 1 To .Offset(, -2).Value
.Value = "◆" & .Value
Next
For i = 1 To .Offset(, -1).Value
.Value = .Value & "●"
Next
For i = 1 To Len(.Value)
If Mid(.Value, i, 1) = "◆" Then
.Characters(i, 1).Font.ColorIndex = 3
ElseIf Mid(.Value, i, 1) = "●" Then
.Characters(i, 1).Font.ColorIndex = 4
End If
Next i
Application.EnableEvents = True
End With
End Sub
他にもエラー処置が必要かも??
*こんなコードにつっ込みも下さい
|
|