|
すみません、再度質問です。
エクセル2002だとシート保護の細かい許可の設定ができるので
数式が入っていても大丈夫だと思ったのですが、2000の環境に
あわせないといけないため、やはりマクロ内にコードを入れて
プロテクトしなくてはいけませんでした。
処理の最初と最後にプロテクト解除、プロテクトのコードを
入れればよいとのことでしたが、入れる場所が違うのか、
最初の行の処理でエラーになってしまいます。
どのようにコードをいれればよいのか教えてください。
よろしくお願いいたします。
Private Sub Worksheet_Change(ByVal Target As Range)
' 計算式セット自体でもイベントが発生するのでイベントを抑制
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"
・
・
・
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
'イベントを再開
Application.EnableEvents = True
End Sub
|
|