Young Grasshopper
Board Regular
- Joined
- Dec 9, 2022
- Messages
- 58
- Office Version
- 365
- 2016
- Platform
- Windows
Hello world,
I have this code to populate a ComboBox-list in a userform;
And I am trying to write a code where VBA is calling a macro if the value in the combobox equals the value in specific cell, and this is what I have;
But this produces nothing.. Any ideas to make it work or do I need to formulate it another way?
Would appreciate any help
I have this code to populate a ComboBox-list in a userform;
VBA Code:
Private Sub UserForm_Initialize()
Dim WS As Worksheet
Dim LastRow As Long
Dim aCell As Range
Set WS = ActiveSheet
With WS
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
For Each aCell In Worksheets("MacroData").Range("A1:A" & LastRow)
If aCell.Value <> "" Then
Me.ComboBox1.AddItem aCell.Value
End If
Next
End With
End Sub
And I am trying to write a code where VBA is calling a macro if the value in the combobox equals the value in specific cell, and this is what I have;
VBA Code:
Private Sub Testbtn_Click()
If Me.ComboBox1.Value = Worksheets("Sheet1").Range("B11").Value Then
Range("A1:X20").Calculate
Call A_preview4
End If
If Me.ComboBox1.Value = Worksheets("Sheet1").Range("B12").Value Then
Range("A1:X20").Calculate
Call A_preview5
End If
End Sub
But this produces nothing.. Any ideas to make it work or do I need to formulate it another way?
Would appreciate any help