Delete vale reference number before user form is populated

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
I populate a user form by copying values from worksheet cells to the user form text boxes.

On my worksheet in column A is the customers name & its eference number.

When I currently populate the user form I see the example shown here entered in text box 1
TOM JONES 002

My goal is that when the value is entered in text box 1 the 002 has been removed.

All the customers on the worksheet will have a space then 3 digits after there name,
Example.
PAUL SMITH 352
JOHN JONES 001

It’s the 352 / 001 along with the space I’m looking to remote when the form is populated so there name is only present.
 
Hi,
This morning it has now decided to do the same as yesterday & show the error message.

On my userform is the command button which confirms a customer selection is made in column A & then opens my userform.
Rich (BB code):
Private Sub RepeatCustomer_Click()
If ActiveCell.Column = 1 Then
DatabaseRepeatCustomer.Show
Else
MsgBox "YOU NEED TO SELECT A CUSTOMER IN COLUMN A", vbCritical, "REPEAT CUSTOMER MESSAGE"
End If

End Sub

When the userform opens my Textboxes are populated with trhe code below.
At the same time the customers name should be trimmed & then populate Textbox8
This is where it fails.
When i debug the line in red below is shown in yellow.

Rich (BB code):
Private Sub UserForm_Initialize()
    
    '-------------------------------
    Me.StartUpPosition = 0
    Me.Top = Application.Top + 70  ' MARGIN FROM TOP OF SCREEN
    Me.Left = Application.Left + Application.Width - Me.Width - 200 ' LEFT / RIGHT OF SCREEN
   
    '-------------------------------
    CommandButton1.Visible = False
    
    Me.TextBox1.Value = Cells(ActiveCell.Row, 18).Value
    Me.TextBox2.Value = Cells(ActiveCell.Row, 19).Value
    Me.TextBox3.Value = Cells(ActiveCell.Row, 20).Value
    Me.TextBox4.Value = Cells(ActiveCell.Row, 21).Value
    Me.TextBox5.Value = Cells(ActiveCell.Row, 22).Value
    Me.TextBox6.Value = Cells(ActiveCell.Row, 23).Value
    Me.TextBox8 = Left(Me.TextBox8, Len(Me.TextBox8) - 4)
    Me.ComboBox1.Value = Cells(ActiveCell.Row, 2).Value
    Me.ComboBox2.Value = Cells(ActiveCell.Row, 3).Value
    Me.ComboBox3.Value = Cells(ActiveCell.Row, 4).Value
    Me.ComboBox4.Value = Cells(ActiveCell.Row, 5).Value
    Me.ComboBox5.Value = Cells(ActiveCell.Row, 6).Value
    Me.ComboBox6.Value = Cells(ActiveCell.Row, 7).Value
    Me.ComboBox7.Value = Cells(ActiveCell.Row, 8).Value
    Me.ComboBox8.Value = Cells(ActiveCell.Row, 9).Value
    Me.ComboBox9.Value = Cells(ActiveCell.Row, 10).Value
    Me.ComboBox10.Value = Cells(ActiveCell.Row, 11).Value
    Me.ComboBox11.Value = Cells(ActiveCell.Row, 12).Value
    Me.ComboBox12.Value = Cells(ActiveCell.Row, 14).Value
    
End Sub
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
That is not the code in post 9 where you said it worked. You are now trying to alter the textbox value when you didn't give it one first.
You really are stuck on using BB tags for vba code, aren't you? :(
 
Upvote 0
I obviously don’t see what you see hence why it might not be working.

The code I’ve put it was I use & can kind if relate to.
 
Upvote 0
I have to go out for a while so I need to keep this short. Go back to post 9 and see what's missing between these two lines you posted today.
Me.TextBox6.Value = Cells(ActiveCell.Row, 23).Value
Me.TextBox8 = Left(Me.TextBox8, Len(Me.TextBox8) - 4)

You are trying to edit the textbox but you have not put anything into it.


The code I’ve put it was I use & can kind if relate to.
Sorry, I don't know what that means.
 
Upvote 0
Yes i see.
I had missed a line of code.

I was trying to delete the 4 characters etc BUT i hadnt populated the Textbox with the customers name etc

Now sorted
Many thanks for your time
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

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