Hello,
I have a Userform that I want to open when a user clicks a cell in a specific column. When the form is submitted the information should be entered in the adjacent cells of the row selected.
For example, If A2 selected the form opens, when the form is submitted the information is entered in B2, C2, D2 and E2. If A3 then B3, C3, D3 and E3 and so on.
So far I have created the form and it displays when I click column A but the programming for entering the information from the form onto the required cells is beyond me.
Here is the code I have so far
</PRE>
</PRE>
Any help someone could offer would be very much appreciated!
Thanks
<!-- / message -->
I have a Userform that I want to open when a user clicks a cell in a specific column. When the form is submitted the information should be entered in the adjacent cells of the row selected.
For example, If A2 selected the form opens, when the form is submitted the information is entered in B2, C2, D2 and E2. If A3 then B3, C3, D3 and E3 and so on.
So far I have created the form and it displays when I click column A but the programming for entering the information from the form onto the required cells is beyond me.
Here is the code I have so far
Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If (Target.Column = 1) And (ActiveSheet.Name = "Sheet1") Then
DinnerPlannerUserForm.Show
End If
If (Target.Column = 1) And (ActiveSheet.Name = "Sheet2") Then
DinnerPlannerUserForm.Show
End If
End Sub
Code:
Private Sub OKButton_Click()
Dim ActiveR As Long
ActiveR = ActiveCell.Row
'Export Data to worksheet
NameTextBox.Value = Cells(ActiveR, 1).Value
PhoneTextBox.Value = Cells(ActiveR, 2).Value
OrderListBox.Value = Cells(ActiveR, 3).Value
ReasonComboBox.Value = Cells(ActiveR, 4).Value
End Sub
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub ClearButton_Click()
Call UserForm_Initialize
End Sub
Private Sub MoneySpinButton_Change()
MoneyTextBox.Text = MoneySpinButton.Value
End Sub
Private Sub UserForm_Initialize()
'Empty NameTextBox
NameTextBox.Value = ""
'Empty PhoneTextBox
PhoneTextBox.Value = ""
'Empty OrderListBox
OrderListBox.Clear
'Fill OrderListBox
With OrderListBox
.AddItem "000025"
.AddItem "000026"
.AddItem "000027"
.AddItem "000028"
End With
'Empty ReasonComboBox
ReasonComboBox.Clear
'Fill ReasonComboBox
With ReasonComboBox
.AddItem "One"
.AddItem "Two"
.AddItem "Three"
End With
End Sub
</PRE>
</PRE>
Any help someone could offer would be very much appreciated!
Thanks
<!-- / message -->