Hi,
I'm making a simple database with a picture in comment on cell D2:
<colgroup><col><col><col><col></colgroup><tbody>
</tbody>
My problem is that I can't get the picture in the comment to a userform.
I really appreciate any help I can get regarding this matter.
I'm making a simple database with a picture in comment on cell D2:
Type of equipment | Manufacturer | Name of equipment | Weight |
Engine | A | W30 | 35 |
Crane | A | R2 | 55 |
Engine | B | W32 | 32 |
<colgroup><col><col><col><col></colgroup><tbody>
</tbody>
My problem is that I can't get the picture in the comment to a userform.
I really appreciate any help I can get regarding this matter.
Code:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim LR As Long
Dim Cell As Range
Dim List As New Collection
Dim Item As Variant
Set ws = ActiveSheet
With ws
LR = .Cells(.Rows.Count, 1).End(xlUp).Row
For Each Cell In .Range("A2:A" & LR)
With Cell
On Error Resume Next
List.Add .Text, CStr(.Value)
On Error GoTo 0
End With
Next Cell
For Each Item In List
ComboBox1.AddItem Item
Next Item
End With
End Sub
Private Sub ComboBox1_Change()
Dim ws As Worksheet
Dim LR As Long
Dim Cell As Range
Dim List As New Collection
Dim Item As Variant
Set ws = ActiveSheet
With ws
LR = .Cells(.Rows.Count, 1).End(xlUp).Row
ComboBox2.Clear
For Each Cell In .Range("A2:A" & LR)
With Cell
If .Text = ComboBox1.Value Then
On Error Resume Next
List.Add .Offset(0, 1).Text, CStr(.Offset(0, 1).Value)
On Error GoTo 0
End If
End With
Next Cell
For Each Item In List
ComboBox2.AddItem Item
Next Item
End With
End Sub
Private Sub ComboBox2_Change()
Dim ws As Worksheet
Dim LR As Long
Dim Cell As Range
Dim List As New Collection
Dim Item As Variant
Set ws = ActiveSheet
With ws
LR = .Cells(.Rows.Count, 1).End(xlUp).Row
ComboBox3.Clear
For Each Cell In .Range("A2:A" & LR)
With Cell
If .Text = ComboBox1.Value Then
If .Offset(0, 1).Text = ComboBox2.Value Then
On Error Resume Next
List.Add .Offset(0, 2).Text, CStr(.Offset(0, 2).Value)
On Error GoTo 0
End If
End If
End With
Next Cell
For Each Item In List
ComboBox3.AddItem Item
Next Item
End With
End Sub
Private Sub ComboBox3_Change()
Dim ws As Worksheet
Dim LR As Long
Dim Cell As Range
Dim List As New Collection
Dim Item As Variant
Dim objComment As Comment
Set ws = ActiveSheet
With ws
LR = .Cells(.Rows.Count, 1).End(xlUp).Row
ComboBox4.Clear
For Each Cell In .Range("A2:A" & LR)
With Cell
If .Text = ComboBox1.Value Then
If .Offset(0, 1).Text = ComboBox2.Value Then
On Error Resume Next
List.Add .Offset(0, 3).Text, CStr(.Offset(0, 3).Value)
On Error GoTo 0
End If
End If
End With
Next Cell
For Each Item In List
ComboBox4.AddItem Item
Next Item
End With
End Sub
Last edited: