MS Excel form to fill from selected row.

DerekP

New Member
Joined
Jul 4, 2012
Messages
1
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

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 -->
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,203,736
Messages
6,057,066
Members
444,903
Latest member
Mavericx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top