Chemical Elements In Excel

Excel Chemical Elements Table


        We created a table of chemical elements in Excel workbook. We have added a simple Excel userform to make it easier to review the properties of chemical elements.

 Our userform has a combobox, a button and text boxes .
We vocalized the selected element name from the combobox  and atomic number with the VBA Speech.Speak method. The related codes :

If ComboBox1 <> Empty Then
  Application.Speech.Speak ComboBox1.Value, Purge:=False, SpeakAsync:=True
  Application.Wait (Now + TimeValue("00:00:01"))
  Application.Speech.Speak "Atomic Number" & atomicno, Purge:=False, SpeakAsync:=True
End If   
 

VBA codes to fill chemical element names to the combobox control (in Userform1_Initialize() procedure) : 

lastrow = Sheets("Chemical_Elements").Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow
ComboBox1.AddItem Cells(i, 1)
Next i

To fill textboxes according to the value in combobox (in ComboBox1_Change() procedure) : 

n = WorksheetFunction.CountA(Range("A:A"))
i = UserForm1.ComboBox1.ListIndex
symbol = Range("A2:A" & n).Cells(i + 1, 3)
atomicno = Range("A2:A" & n).Cells(i + 1, 4

To highlight cell in worksheet when selected the combobox item (in ComboBox1_Change() procedure) : 

Sheets("Chemical_Elements").Activate
If ComboBox1 <> Empty Then
Sheets("Chemical_Elements").Range("A2:A" & lastrow).Find(What:=ComboBox1.Value, LookIn:=xlValues, LookAt:=xlWhole).Activate
Else
Sheets("Chemical_Elements").Range("A1").Select
End If

Previous Post Next Post