Sie sind auf Seite 1von 4

Sub E_Code()

'GoTo_Last_Empty_Row
Range("K1").Select
Selection.End(xlDown).Select
i = ActiveCell.Row + 1
'Unlock_The_Sheet
ActiveSheet.Unprotect
Cells.Select
Selection.Locked = False
Selection.FormulaHidden = False
'Data_Validation_IWK
With Range("B:B").Validation
.Delete
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=countif(B:B,B1)=1"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "IWK Part Number"
.ErrorTitle = "Duplicate Part Number"
.InputMessage = "Please Enter IWK part Number here"
.ErrorMessage = "E-code for this part number already exists in the syste
m"
.ShowInput = True
.ShowError = True
End With
a = i
Cells(a, 2).Select
Do While Cells(a, 2) <> ""
If Application.WorksheetFunction.CountIf(Range("B1", Cells(a, 2)), Cell
s(a, 2)) <> 1 Then
Cells(a, 2).Select
Application.SendKeys "{F2}"
Application.SendKeys "{ENTER}"
Exit Sub
End If
a = a + 1
Loop

'Data_Validation_Pester
With Range("C:C").Validation
.Delete
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _

xlBetween, Formula1:="=countif(C:C,C1)=1"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
b = i
Cells(b, 3).Select
Do While Cells(b, 3) <> ""
If Application.WorksheetFunction.CountIf(Range("C1", Cells(b, 3)), Cell
s(b, 3)) <> 1 Then
Cells(b, 3).Select
Application.SendKeys "{F2}"
Application.SendKeys "{ENTER}"
Exit Sub
End If
b = b + 1
Loop
'Data_Validation_OEM
With Range("D:D").Validation
.Delete
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=countif(D:D,D1)=1"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
c = i
Cells(c, 4).Select
Do While Cells(c, 4) <> ""
If Application.WorksheetFunction.CountIf(Range("D1", Cells(c, 4)), Cell
s(c, 4)) <> 1 Then
Cells(c, 4).Select
Application.SendKeys "{F2}"
Application.SendKeys "{ENTER}"
Exit Sub
End If

c = c + 1
Loop
'Code_Generate
d = i
e = d
Line1:
Cells(d, 10).FormulaR1C1 = "=RC[-2]&RC[-1]"
Cells(d, 11).FormulaR1C1 = _
"=IF(LEN(RC[-4]&RC[-1])<>8,""Please Correct The Data"",R1C10&RC[-4]&RC
[-1]&TEXT(COUNTIF(R2C10:RC[-1],RC[-1]),""0000""))"
Cells(d, 12).FormulaR1C1 = "=RC[-6]&"" ""&RC[-8]&"" : ""&RC[-10]&"" : ""&RC[
-9]"
d = d + 1
'Lock
'Unlock_First
ActiveSheet.Unprotect
Selection.Locked = False
Selection.FormulaHidden = False
Range("K1").End(xlDown).Select
If ActiveCell.Value = "Please Correct The Data" Then
Range(Cells(d, 10), Cells(i, 12)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Cells(1, 2).Copy
Range(Cells(d, 1), Cells(i, 12)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range(Cells(i, 12), Cells(d, 12)).Select
Selection.Value = Application.Proper(Selection.Value)
Selection.Locked = False
Selection.FormulaHidden = False
Range(Rows(d - 2), Rows(1)).Select
Selection.Locked = True

Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Cells(i, 11).Select
Exit Sub
Else: GoTo Line1

ActiveSheet.Unprotect
Range(Rows(d - 2), Rows(1)).Select
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Cells(i, 11).Select
End If
End Sub

Das könnte Ihnen auch gefallen