'Macro launches userform from activesheet, but want to auto-paste cell value from activesheet into userform's combobox
Looking for a little help here. Summary below.
GOAL: When I run a macro module from an activesheet, the following steps are automated:
- Launches a userform with multiple ComboBoxes and buttons
- Copies the text in cells(activecell.row, 1)
- Pastes the text into the 1st ComboBox on userform labeled DPComboBox
I can do 1 and 2, but 3 fails whether I do the pasting in the vba code of the module or the vba code of the ComboBox. I can manually paste once the userform is displayed since the copy works, but I want to automate the step.
Macro Module
Sub Show_Quick_Commands()
ThisWorkbook.ActiveSheet.Cells(ActiveCell.Row, 1).Copy
CommandsUserForm.Show vbModeless
DPComboBox.Select
DPComboBox.Paste
End Sub
Macro ComboBox (currently not attempting paste here, but happy with everything else in this code)
Private Sub DPComboBox_Change()
ActiveDPLastRow = ThisWorkbook.ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For i = 3 To ActiveDPLastRow
If (ThisWorkbook.ActiveSheet.Cells(i, 1).Value = DPComboBox.Value) Then
ThisWorkbook.ActiveSheet.Cells(i, 2).Copy
PCComboBox.Paste
ThisWorkbook.ActiveSheet.Cells(i, 4).Copy
DISComboBox.Paste
End If
Next i
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
