Pre-populate a User Form based on current row

AlInVegas2

New Member
Joined
Jun 19, 2019
Messages
25
I'm trying to prepopulate a userform I created with the data from the Active Cell Row. After performing the userform.show, I am having difficulty populating the various text boxes with the values in the given row. It may have to do with the way I'm activating the form or something. Any suggestions?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try something like:
VBA Code:
Private Sub UserForm_Initialize()

Dim c As Range

Set c = Intersect(ActiveCell.EntireRow, Columns(1)) 'Column A

    With Me
        .TextBox1.Value = c.Value
        .TextBox2.Value = c.Offset(, 1).Value
        .TextBox3.Value = c.Offset(, 2).Value
    End With

End Sub
 
Upvote 0
Thanks for your response.

So the name of the form is EngUpdate. The Private Sub EngUpdate_Initialize() opens the form, but the first text field named EClient is blank when the form opens. The Active Row on Sheet 5 (Engagement Completion) has a client name. It's just not showing up on the form. Here's the code I wrote:

Private Sub EngUpdate_Initialize()

Dim c As Range
Set c = Intersect(ActiveCell.EntireRow, Columns(1))
With Me
.EClient.Value = c.Value
End With
End Sub

Any suggestions as to where I went wrong? My objective is to pull the key field values currently and subsequently update them with any changes I make when submitting.
 
Last edited:
Upvote 0
You should not change the name of the initialize event, it should always be
VBA Code:
Private Sub UserForm_Initialize()
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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