Bonjour,
je souhaiterais faire un check sur le contenu d'une cellule.
Je m'explique:
J'ai les cellule de D7 a D% ou je vais entrer une valeur commençant soit par B_% soit par NB_%
Je voudrais qu'il me jette si mes valeurs ne commence pas par une de ces 2 possibilités.
Voila le code que j'ai pour le moment, ou je voudrais ajouter cette fonctionnalité.
Option Explicit
'Fills the field of static with a formatted name
Sub createStaticName()
Dim brickName As String
Dim staticName As String
Dim reg As New VBScript_RegExp_55.RegExp
Dim rw As Integer
'old reg.Pattern = "(B_)((L)INE|(V)IA)([0-9]{0,2})(_[A-Z]*[0-9]*)_([TX-Z][1-9]+)(-[0-9]+)\n*"
reg.Pattern = "(\$[A-Z0-9_]*?)(_(?:USL|LSL|TGT))(N?B)([A-Z0-9_]*?)-[0-9]+\n*"
rw = 7
Application.ScreenUpdating = False
While Cells(rw, 1).Value <> "" And Cells(rw, 4).Value <> ""
Cells(rw, 1).Value = Replace(Cells(rw, 1).Value, "DENSITY", "DENS")
Cells(rw, 1).Value = Replace(Cells(rw, 1).Value, "RANDOM", "RAND")
If Cells(rw, 6) = "" Then
brickName = Cells(rw, 4).Value
brickName = Replace(brickName, "PATTERNING", "PAT")
brickName = Replace(brickName, "DEFINITION", "DEF")
brickName = Replace(brickName, "RANDOM", "RAND")
brickName = Replace(brickName, "PARAMETRIC", "PAR")
brickName = Replace(brickName, "COLOR", "COL")
brickName = Replace(brickName, "FORMATION", "FORM")
brickName = Replace(brickName, "CLASSIF", "CLAS")
brickName = Replace(brickName, "FILLING", "FILL")
brickName = Replace(brickName, "UCAVITY", "UCAV")
brickName = Replace(brickName, "DRAMBEOL", "DRAMB")
brickName = Replace(brickName, "LINE", "LIN")
brickName = Replace(brickName, "WAF", "WF")
brickName = Replace(brickName, "NAILPROCESSING", "NAILPROC")
brickName = Replace(brickName, "ANNEAL", "ANN")
brickName = Replace(brickName, "CUPILLAR", "CUPIL")
brickName = Replace(brickName, "SPACERZERO", "SPACERZ")
brickName = Replace(brickName, "DEFECT", "DEFT")
brickName = Replace(brickName, "HIK", "HK")
brickName = Replace(brickName, "FORMATION", "FORM")
brickName = Replace(brickName, "CTE2BEOL", "CTE2B")
brickName = Replace(brickName, "PASSIVATION", "PASSIV")
brickName = Replace(brickName, "FILTER", "FILT")
brickName = Replace(brickName, "REMOVAL", "REMOV")
brickName = Replace(brickName, "SPACERHVZERO", "SPACHVZ")
staticName = Cells(rw, 1).Value & brickName
staticName = reg.Replace(staticName, "$1$4$2")
If Right(staticName, 3) = "LSL" Then
Cells(rw, 2).Value = "Lower Spec Limit"
ElseIf Right(staticName, 3) = "USL" Then
Cells(rw, 2).Value = "Upper Spec Limit"
ElseIf Right(staticName, 3) = "TGT" Then
Cells(rw, 2).Value = "Target Limit"
Else
Cells(rw, 2).Value = "???"
End If
Cells(rw, 3).Value = "Plan"
Cells(rw, 5).Value = "String"
Cells(rw, 6).Value = staticName
Cells(rw, 7).Value = "Static"
Cells(rw, 8).Value = "T"
End If
rw = rw + 1
Wend
Application.ScreenUpdating = True
End Sub
Sub createParamName(ByRef Target As Range)
Dim paramName As String
Dim curCell As Range
Dim nblines As Integer
Dim i As Integer
Dim curRow As Integer
nblines = 0
For Each curCell In Selection
If curCell.Column = 1 And curCell.Row >= 7 Then
nblines = nblines + 1
End If
Next
curRow = Target.Row
For i = 1 To nblines
If Left(Cells(curRow, 1), 1) <> "$" Then
Rows(curRow).Select
Selection.Copy
Selection.Insert Shift:=xlDown
paramName = shortName(Cells(curRow, 1).Value, "-")
Cells(curRow, 1) = "$" & paramName & "_LSL"
Cells(curRow + 1, 1) = "$" & paramName & "_USL"
Cells(curRow, 1).Value = Replace(Cells(curRow, 1).Value, "$DF_", "$DE_")
Cells(curRow + 1, 1).Value = Replace(Cells(curRow + 1, 1).Value, "$DF_", "$DE_")
Cells(curRow, 1).Value = Replace(Cells(curRow, 1).Value, "RANDOM", "RAND")
Cells(curRow + 1, 1).Value = Replace(Cells(curRow + 1, 1).Value, "RANDOM", "RAND")
curRow = curRow + 2
Else
curRow = curRow + 1
End If
Next
End Sub
Function shortName(item As String, strTokenChar As String) As String
Dim pos As Integer
pos = InStr(1, item, strTokenChar)
If pos > 0 Then
shortName = Left(item, pos - 1)
Else
shortName = item
End If
End Function
Merci pour votre aide.
Cordialement
Bylbo.