PDA

View Full Version : [SLEEPER:] Automatically populate userform from row selection in excel



RoadDog83
09-29-2009, 02:59 PM
so basically i want to select a cell which upon selection will automatically select the entire row.

then click the edit info button which will intialize the userform

once userform shows up it populates with the selected information

once im done editing it and click okay i want it to change the contents of the cells in that same row with what's in my userform.

mdmackillop
09-29-2009, 03:41 PM
No need to select the row. Something like


Option Explicit

Dim RW As Long

Private Sub UserForm_Initialize()
RW = ActiveCell.Row
Me.TextBox1.Value = Cells(RW, 1)
Me.TextBox2.Value = Cells(RW, 2)
Me.TextBox3.Value = Cells(RW, 3)
End Sub

Private Sub CommandButton1_Click()
Cells(RW, 1) = Me.TextBox1.Value
Cells(RW, 2) = Me.TextBox2.Value
Cells(RW, 3) = Me.TextBox3.Value
Unload UserForm1
End Sub

RoadDog83
09-29-2009, 04:13 PM
do i need 2 user forms then?

1 to input information in the first place?
and
1 to edit the information?

mdmackillop
09-29-2009, 04:19 PM
No, the data is loaded, then you edit it.