Function GEFAHRSTOFFSYMBOL() ' hazardous substance symbol
Dim ZEILE As Variant 'ROW
Dim ZEILE_ANFANG As Variant 'LINE_START
Dim ZEILE_ENDE As Variant 'LINE_END
Dim COLUMN As Variant
Dim FIRST_COLUMN As Variant
Dim LAST_COLUMN As Variant
Dim FELD As Variant 'FIELD
Dim ZAEHLER As Variant 'COUNTER
Dim HOEHE As Variant 'HEIGHT
Dim BRENNBAR As Variant 'FLAMMABLE
Dim EXPLOSIV As Variant 'EXPLOSIVE
Dim AETZEND As Variant 'CORRISIVE
Dim GIFTIG As Variant 'POISONOUS
Dim GESUNDHEITSSCHAEDLICH As Variant 'HARMFUL
Dim BILD As Picture 'IMAGE
Dim GHS1 As String
Dim GHS2 As String
Dim GHS3 As String
Dim GHS4 As String
Dim GHS5 As String
Dim GHS6 As String
Dim GHS7 As String
Dim GHS8 As String
Dim GHS9 As String
Dim TEXT As String
Dim BEZEICHNUNG As String 'DESCRIPTION
Dim ADRESSE As String 'ADDRESS
'Dim H_SAETZE As Integer 'H_PHRASE
Dim GHS_NUMMERN As String 'GHS_NUMBERS
Dim GHS_SYMBOLE As String 'GHS_SYMBOL
'Hier kommt der Definitionsteil, in dem alle Parameter eingestellt werden
'Here comes the definition part, in which all parameters are set
'************************************************************************
ZEILE_ANFANG = 5 'Ab welcher Zele sollen die GHS-Symbole eingesetzt werden --- From which row should the GHS symbols be used
ZEILE_ENDE = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
'ZEILE_ENDE = 100 'Bis zu welcher Zele sollen die GHS-Symbole eingesetzt werden --- Up to which line should the GHS symbols be used
FIRST_COLUMN = 10
LAST_COLUMN = 17
'H_SAETZE = 14 'In welcher Spalte stehen die H-Sätze --- In which column are the H_Phrases
GHS_NUMMERN = "I" 'In welche Spalte sollen die GHS-Nummern eingefügt werden --- In which column should the GHS numbers be inserted
ADRESSE = "Pictograms" 'In welchem Ordner liegen die GHS-Symbole --- In which folder are the GSH Symbols located
'ADRESSE = "K:\QUALITY\Hazard Symbols\"
HOEHE = 29 'Wie hoch sollen die GHS-Symbole sein --- How high should the GHS symbols be
GHS_SYMBOLE = "H" 'In welche Spalte sollen die GHS-Symbole eingesetzt werden --- In which column should the GHS symbols be placed
'************************************************************************
'Hier endet der Definitionsteil, in dem alle Parameter eingestellt werden
'This is where the definition section ends, in which all parameters are set
'Folgende Ausschlussbedingungen gibt es:
'There are the following exclusion conditions:
'************************************************************************
'a) Wenn GHS01 dann kein GHS02 und GHS03 --- IF GHS01 THEN NO GHS02 AND GHS03
'b) Wenn GHS06 dann kein GHS07 --- IF GHS06 THEN NO GHS07
'c) Wenn GHS05 und H315 oder H319 dann kein GHS07 --- IF GHS05 AND H315 OR H319 THEN NO GHS07
'd) WENN GHS08 und H315 oder H317 oder H319 dann kein GHS07 --- IF GHS08 AND H315 OR H317 OR H319 THEN NO GHS07
'e) Wenn GHS02 oder GHS06 dann kein GHS04 --- IF GHS02 OR GHS06 THEN NO GHS04
'************************************************************************
'Hier endet die Beschreibung der Ausschlussbedingungen
'The description of the exclusion conditions ends here
For Each wks In ActiveWorkbook.Worksheets 'Folgende Routine setzt alle Filterungen zurück, da sonst das Programm nicht richtig funktioniert --- The following routine removes all filters, otherwise the program will not work properly
With wks
If .FilterMode Then .ShowAllData
End With
Next wks
ActiveSheet.Pictures.Delete 'Bei jedem Programmaufruf werden alle Bilder erst einmal gelöscht, sonst würden immer mehr Bilder übereinander abgelegt --- Each time the program is called, all images are first deleted, otherwise more and more images would be stored on top of each other
ActiveSheet.Range("I5:I100").ClearContents
Columns(GHS_SYMBOLE).ColumnWidth = HOEHE 'HEIGHT
For ZEILE = ZEILE_ANFANG To ZEILE_ENDE 'FOR ROW = ROW_START TO ROW_END
For COLUMN = FIRST_COLUMN To LAST_COLUMN - 1
GHS1 = ""
GHS2 = ""
GHS3 = ""
GHS4 = ""
GHS5 = ""
GHS6 = ""
GHS7 = ""
GHS8 = ""
GHS9 = ""
'TEXT = Range(H_SAETZE & ZEILE) ' RANGE(H_PHRASE & ROW)
TEXT = Cells(ZEILE, COLUMN).Value
'TEXT = Cells(4, 14).Value
BRENNBAR = 0 ' FLAMMABLE
EXPLOSIV = 0 ' EXPLOSIVE
AETZEND = 0 ' CORROSIVE
GIFTIG = 0 ' POISONOUS
GESUNDHEITSSCHAEDLICH = 0 ' HARMFUL
If InStr(TEXT, "200") Then
GHS1 = "Picture 1, "
EXPLOSIV = 1
End If
If InStr(TEXT, "201") Then
GHS1 = "Picture 1, "
EXPLOSIV = 1
End If
If InStr(TEXT, "202") Then
GHS1 = "Picture 1, "
EXPLOSIV = 1
End If
If InStr(TEXT, "203") Then
GHS1 = "Picture 1, "
EXPLOSIV = 1
End If
If InStr(TEXT, "204") Then
GHS1 = "Picture 1, "
EXPLOSIV = 1
End If
If InStr(TEXT, "240") Then
GHS1 = "Picture 1, "
EXPLOSIV = 1
End If
If InStr(TEXT, "241") Then
GHS1 = "Picture 1, "
EXPLOSIV = 1
End If
If EXPLOSIV = 0 Then
If InStr(TEXT, "220") Then
GHS2 = "Picture 2, "
BRENNBAR = 1 ' FLAMMABLE
End If
If InStr(TEXT, "222") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "223") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "224") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "225") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "226") Then
GHS2 = "Picture 2, "
End If
If InStr(TEXT, "228") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "241") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "242") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "250") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "251") Then
GHS2 = "Picture 2, "
End If
If InStr(TEXT, "252") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "260") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "261") Then
GHS2 = "Picture 2, "
BRENNBAR = 1
End If
If InStr(TEXT, "270") Then
GHS3 = "Picture 3, "
End If
If InStr(TEXT, "271") Then
GHS3 = "Picture 3, "
End If
If InStr(TEXT, "272") Then
GHS3 = "Picture 3, "
End If
End If
If InStr(TEXT, "300") Then
GHS6 = "Picture 6, "
GIFTIG = 1 ' POISONOUS
End If
If InStr(TEXT, "301") Then
GHS6 = "Picture 6, "
GIFTIG = 1
End If
If InStr(TEXT, "310") Then
GHS6 = "Picture 6, "
GIFTIG = 1
End If
If InStr(TEXT, "311") Then
GHS6 = "Picture 6, "
GIFTIG = 1
End If
If InStr(TEXT, "330") Then
GHS6 = "Picture 6, "
GIFTIG = 1
End If
If InStr(TEXT, "331") Then
GHS6 = "Picture 6, "
GIFTIG = 1
End If
If BRENNBAR = 0 Then
If GIFTIG = 0 Then
If InStr(TEXT, "280") Then
GHS4 = "Picture 4, "
End If
If InStr(TEXT, "281") Then
GHS4 = "Picture 4, "
End If
End If
End If
If InStr(TEXT, "290") Then
GHS5 = "Picture 5, "
AETZEND = 1 ' CORROSIVE
End If
If InStr(TEXT, "314") Then
GHS5 = "Picture 5, "
AETZEND = 1
End If
If InStr(TEXT, "318") Then
GHS5 = "Picture 5, "
AETZEND = 1
End If
If InStr(TEXT, "334") Then
GHS8 = "Picture 8, "
GESUNDHEITSSCHAEDLICH = 1 ' HARMFUL
End If
If InStr(TEXT, "340") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "341") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "350") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "351") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "360") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "361") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "370") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "371") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "372") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "373") Then
GHS8 = "Picture 8, "
End If
If InStr(TEXT, "304") Then
GHS8 = "Picture 8, "
End If
If GIFTIG = 0 Then
If InStr(TEXT, "302") Then
GHS7 = "Picture 7, "
End If
If InStr(TEXT, "312") Then
GHS7 = "Picture 7, "
End If
If InStr(TEXT, "332") Then
GHS7 = "Picture 7, "
End If
If AETZEND = 0 Then
If GESUNDHEITSSCHAEDLICH = 0 Then
If InStr(TEXT, "315") Then
GHS7 = "Picture 7, "
End If
If InStr(TEXT, "319") Then
GHS7 = "Picture 7, "
End If
End If
End If
If GESUNDHEITSSCHAEDLICH = 0 Then
If InStr(TEXT, "317") Then
GHS7 = "Picture 7, "
End If
End If
If InStr(TEXT, "335") Then
GHS7 = "Picture 7, "
End If
If InStr(TEXT, "336") Then
GHS7 = "Picture 7, "
End If
If InStr(TEXT, "420") Then
GHS7 = "Picture 7, "
End If
End If
If InStr(TEXT, "400") Then
GHS9 = "Picture 9, "
End If
If InStr(TEXT, "410") Then
GHS9 = "Picture 9, "
End If
If InStr(TEXT, "411") Then
GHS9 = "Picture 9, "
End If
Range(GHS_NUMMERN & ZEILE) = Range(GHS_NUMMERN & ZEILE) + GHS1 + GHS2 + GHS3 + GHS4 + GHS5 + GHS6 + GHS7 + GHS8 + GHS9 ' GHS_NUMBERS & ROW)
'TEXT = Range(GHS_NUMMERN & ZEILE).Value
Next
Next
For ZEILE = ZEILE_ANFANG To ZEILE_ENDE 'Jede Zeile wird überprüft --- Every line is checked
TEXT = Range(GHS_NUMMERN & ZEILE)
ZAEHLER = 0
For FELD = 1 To 9 'Jedes Gefahrensymbol wird gesucht --- Every danger symbol is searched for
Select Case FELD ' FIELD
Case Is = 1
BEZEICHNUNG = "Picture 1" '"GHS01" ' DESCRIPTION
Case Is = 2
BEZEICHNUNG = "Picture 2" '"GHS02"
Case Is = 3
BEZEICHNUNG = "Picture 3" '"GHS03"
Case Is = 4
BEZEICHNUNG = "Picture 4" '"GHS04"
Case Is = 5
BEZEICHNUNG = "Picture 5" '"GHS05"
Case Is = 6
BEZEICHNUNG = "Picture 6" '"GHS06"
Case Is = 7
BEZEICHNUNG = "Picture 7" '"GHS07"
Case Is = 8
BEZEICHNUNG = "Picture 8" '"GHS08"
Case Is = 9
BEZEICHNUNG = "Picture 9" '"GHS09"
End Select
If InStr(TEXT, BEZEICHNUNG) Then
'Set BILD = ActiveSheet.Pictures.Insert(ADRESSE + BEZEICHNUNG + ".png") 'Hier wird die Adresse des Bildes generiert
Set BILD = ActiveSheet.Pictures.Insert(ADRESSE + BEZEICHNUNG)
With BILD 'Das Bild wird eingefügt --- The picture is inserted
.ShapeRange.LockAspectRatio = msoFalse
.Height = HOEHE
.Width = HOEHE
.Top = Range(GHS_SYMBOLE & ZEILE).Top + 1
.Left = Range(GHS_SYMBOLE & ZEILE).Left + ZAEHLER + 1 ' COUNTER
.Placement = xlMoveAndSize
End With
'Range(GHS_SYMBOLE & ZEILE).FormulaLocal = "=CHAR(10)"
Set BILD = Nothing
ZAEHLER = ZAEHLER + HOEHE
End If
Next
Next
ActiveSheet.Range(GHS_SYMBOLE & ZEILE_ANFANG & ":" & GHS_SYMBOLE & ZEILE_ENDE).Rows.EntireRow.AutoFit
End Function