Chemical Elements In Excel

Excel VBA 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 .

Our codes :
- To fill 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):
i = UserForm1.ComboBox1.ListIndex
symbol = Range(“A2:A” & n).Cells(i + 1, 3)
atomicno = Range(“A2:A” & n).Cells(i + 1, 4)
atomicmass = Range(“A2:A” & n).Cells(i + 1, 2)

- To highlight cell when selected the combobox item (in ComboBox1_Change() procedure):
lastrow = Sheets(“Chemical_Elements”).Cells(Rows.Count, “A”).End(xlUp).Row
Sheets(“Chemical_Elements”).Range(“A2:A” & lastrow).Find(What:=ComboBox1.Value,
LookIn:=xlValues, LookAt:=xlWhole).Activate

No comments:

Post a Comment