always_confused
Board Regular
- Joined
- Feb 19, 2021
- Messages
- 68
- Office Version
- 2016
- Platform
- Windows
Hello,
I have a sheet with time stamp values in column B. They are formatted as DD/MM/YYYY HH:MM:SS. I am trying to make a combobox to use as a menu to select a MM/YYYY for further calculations. My issue is:
I have 2 subs, one to make the combobox:
and one to fill the box:
I can run the first Sub and then the second one, and it works fine. However, when I try to call them together either in the same Sub by just copying and pasting their content into the same Sub, or if I call them both in a Sub, the box is made, but it's empty.
A colleague tried the copy and paste method on his computer (Excel 2019) and it worked. On my computer (Excel 2016) it does not. Is this possibly a limit of my Excel or am I doing something wrong?
I have a sheet with time stamp values in column B. They are formatted as DD/MM/YYYY HH:MM:SS. I am trying to make a combobox to use as a menu to select a MM/YYYY for further calculations. My issue is:
I have 2 subs, one to make the combobox:
VBA Code:
Sub make_box()
Dim pos As Range
Set pos = Sheets("MySheet").Range("V2:W4")
ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False, _
DisplayAsIcon:=False, Left:=pos.Left, Top:=pos.Top, Width:=pos.Width, Height:=pos.Top) _
.Select
End Sub
and one to fill the box:
VBA Code:
Sub Populate_combobox_with_Unique_values()
Dim vStr, eStr
Dim dObj As Object
Dim xRg As Range
Dim rng As Range
Dim lastrow As Long
lastrow = Sheets("lot").Range("B" & Rows.Count).End(xlUp).Row
Set rng = Sheets("lot").Range("B2:B" & lastrow)
On Error Resume Next
Set dObj = CreateObject("Scripting.Dictionary")
Set xRg = rng
vStr = xRg.Value
With dObj
.comparemode = 1
For Each eStr In vStr
If Not .exists(Mid(eStr, 4, 7)) And eStr <> "" Then .Add Mid(eStr, 4, 7), Nothing
Next
If .Count Then
Sheets("DerivePosage").ComboBox1.List = WorksheetFunction.Transpose(.keys)
End If
End With
End Sub
I can run the first Sub and then the second one, and it works fine. However, when I try to call them together either in the same Sub by just copying and pasting their content into the same Sub, or if I call them both in a Sub, the box is made, but it's empty.
A colleague tried the copy and paste method on his computer (Excel 2019) and it worked. On my computer (Excel 2016) it does not. Is this possibly a limit of my Excel or am I doing something wrong?