Variable does't show in userform textbox

colinharwood

Active Member
Joined
Jul 27, 2002
Messages
380
Hi
I have the following code, which runs when a command button on a userform is pressed.
I would like the userform1 called to have the variables First & Last shown in the two textboxes on the userform1, but they just show a cursor.
If I look in the debug window, the two variable show the right reults, but they will not show in the textboxes.
Any help much appreciated

Private Sub update_Click()
Dim lastRow
Dim First As String
Dim Last As String

Sheets("TMES Members").Select
Application.ScreenUpdating = False

First = AKA.Text
Last = Surname.Text

lastRow = Range("B200").End(xlUp).Offset(1, -1).Row

Range("B" & lastRow).Value = Surname.Value
Range("C" & lastRow).Value = AKA.Text
Range("D" & lastRow).Value = Forenames.Text


SortAndAddBorders

NewMember.Hide

Application.ScreenUpdating = True


UserForm1.Show
TextBox1.Value = First
TextBox2.Value = Last
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,178
Office Version
  1. 2019
Platform
  1. Windows
Hi,
Try
VBA Code:
    With UserForm1
            .TextBox1.Value = First
            .TextBox2.Value = Last
            .Show
    End With

Dave
 

colinharwood

Active Member
Joined
Jul 27, 2002
Messages
380
Thanks for that, I also had to remove the userform1.show, else the form showed empty, press ok and then it showed with the values
Thanks again
 

Watch MrExcel Video

Forum statistics

Threads
1,114,335
Messages
5,547,332
Members
410,785
Latest member
phillippaige
Top