|
▼やっちん さん:
よろしくお願いいたします。
エラー箇所は、Worksheets("Sheet1").Unprotect
「カーソル下の識別子を認識できません」となっています。
Private Sub Worksheet_Change(ByVal Target As Range)
' 計算式セット自体でもイベントが発生するのでイベントを抑制
Worksheets("Sheet1").Unprotect
Application.EnableEvents = False
Dim v As Integer
Dim Size_S As String
Dim Size_M As String
Dim Size_L As String
Dim Size_O As String
Dim Size_XO As String
Dim Size_ML As String
Dim Size_OXO As String
Dim Size_LL As String
Dim Size_FREE As String
Dim Size_25_27 As String
Dim Size_Nothing As String
Dim Ladies_S As String
Dim Ladies_M As String
Dim Ladies_L As String
Dim Ladies_FREE As String
Dim strTEXT As String
Dim lngEndROW As Long
'最終行取得
lngEndROW = Range("E65536").End(xlUp).Row
If lngEndROW < 8 Then Exit Sub
For v = 8 To lngEndROW
'IIf(expr, truepart, falsepart)
Size_S = IIf(Range("G" & v).Value = "", "", "S/" & Range("G" & v).Value & ",")
Size_M = IIf(Range("I" & v).Value = "", "", "M/" & Range("I" & v).Value & ",")
Size_L = IIf(Range("K" & v).Value = "", "", "L/" & Range("K" & v).Value & ",")
Size_O = IIf(Range("M" & v).Value = "", "", "O/" & Range("M" & v).Value & ",")
Size_XO = IIf(Range("O" & v).Value = "", "", "XO/" & Range("O" & v).Value & ",")
Size_ML = IIf(Range("I" & v).Value = "", "", "M-L/" & Range("I" & v).Value & ",")
Size_OXO = IIf(Range("K" & v).Value = "", "", "O-XO/" & Range("K" & v).Value & ",")
Size_LL = IIf(Range("M" & v).Value = "", "", "LL/" & Range("M" & v).Value & ",")
Size_FREE = IIf(Range("Q" & v).Value = "", "", "フリー/" & Range("Q" & v).Value & ",")
Size_25_27 = IIf(Range("S" & v).Value = "", "", "25-27cm/" & Range("S" & v).Value & ",")
Size_Nothing = IIf(Range("U" & v).Value = "", "", "/" & Range("U" & v).Value & ",")
Ladies_S = IIf(Range("G" & v).Value = "", "", "レディースS/" & Range("G" & v).Value & ",")
Ladies_M = IIf(Range("I" & v).Value = "", "", "レディースM/" & Range("I" & v).Value & ",")
Ladies_L = IIf(Range("K" & v).Value = "", "", "レディースL/" & Range("K" & v).Value & ",")
Ladies_FREE = IIf(Range("M" & v).Value = "", "", "レディースフリー/" & Range("M" & v).Value & ",")
Select Case Cells(v, 5).Value
'値の取得(前br)
Case "A"
strTEXT = Size_S & Size_M & Size_L & Size_O & Size_XO
Range("E" & v).Interior.Color = RGB(0, 128, 128)
Range(Cells(v, 6), Cells(v, 20)).Interior.ColorIndex = xlNone
Range(Cells(v, 13), Cells(v, 20)).Interior.Color = RGB(192, 192, 192)
Case "B"
strTEXT = Size_ML & Size_OXO & Size_LL
Range("E" & v).Interior.Color = RGB(51, 204, 204)
Range(Cells(v, 6), Cells(v, 20)).Interior.ColorIndex = xlNone
Range(Cells(v, 14), Cells(v, 20)).Interior.Color = RGB(192, 192, 192)
Range("F" & v).Interior.Color = RGB(192, 192, 192)
Case "C"
strTEXT = Size_FREE
Range("E" & v).Interior.Color = RGB(153, 204, 255)
Range(Cells(v, 6), Cells(v, 20)).Interior.ColorIndex = xlNone
Range(Cells(v, 6), Cells(v, 14)).Interior.Color = RGB(192, 192, 192)
Range(Cells(v, 18), Cells(v, 20)).Interior.Color = RGB(192, 192, 192)
Case "D"
strTEXT = Size_25_27
Range("E" & v).Interior.Color = RGB(204, 153, 255)
Range(Cells(v, 6), Cells(v, 20)).Interior.ColorIndex = xlNone
Range(Cells(v, 6), Cells(v, 16)).Interior.Color = RGB(192, 192, 192)
Range(Cells(v, 20), Cells(v, 21)).Interior.Color = RGB(192, 192, 192)
Case "E"
strTEXT = Size_Nothing
Range("E" & v).Interior.Color = RGB(255, 204, 153)
Range(Cells(v, 6), Cells(v, 20)).Interior.ColorIndex = xlNone
Range(Cells(v, 6), Cells(v, 18)).Interior.Color = RGB(192, 192, 192)
Case "F"
strTEXT = Ladies_S & Ladies_M & Ladies_L & Ladies_FREE
Range("E" & v).Interior.Color = RGB(255, 153, 204)
Range(Cells(v, 6), Cells(v, 20)).Interior.ColorIndex = xlNone
Range(Cells(v, 14), Cells(v, 20)).Interior.Color = RGB(192, 192, 192)
End Select
If strTEXT <> "" Then
'文字列(strTEXT,カンマ削除)
strTEXT = Left(strTEXT, Len(strTEXT) - 1)
Cells(v, 24).Value = strTEXT
strTEXT = ""
End If
If Range("E" & v) = "" Then
Range("E" & v).Interior.Color = RGB(255, 255, 255)
MsgBox "カテゴリーを入力してください!", vbOKOnly, "カテゴリー"
Exit For
End If
Next v
Worksheets("Sheet1").Protect
'イベントを再開
Application.EnableEvents = True
End Sub
|
|