Variable does't show in userform textbox

colinharwood

Active Member
Joined
Jul 27, 2002
Messages
426
Office Version
  1. 2019
Platform
  1. Windows
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
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi,
Try
VBA Code:
    With UserForm1
            .TextBox1.Value = First
            .TextBox2.Value = Last
            .Show
    End With

Dave
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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