Userform Text Box Displays End of Text String

Pacman52

Active Member
Joined
Jan 29, 2009
Messages
309
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have created a userform with a textbox for the user to enter text information on a specific location. When they click the 'enter' button on the userform the text is entered into the relevant active cell.

The issue I am having is that the text that is actually displayed in the cell is at the end of the sentence rather than at the beginning.

I.e. If a user entered "London W1A 2BE - Go to Green Door" then "to Green Door" is what is displayed in the cell instead of "London W1A"

I have checked to properties of the textbox and the formatting of the actual cell and I just can't figure out why it is doing this.

could someone offer me any advice on how to resolve this please?

Many thanks

Paul
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi Trevor,

Thanks for the reply

I have the following code to open the userform
Code:
[ Set Target = Target.Cells(1, 1)
    If Not Intersect(Target, Range("F4:F110")) Is Nothing Then
        Cancel = True
        xrow = Target.Row
        strCellText = Target.Value
        frmEL.Show
    End If
/CODE]

and then this code behind the command button (Enter)

[CODE][Private Sub CmdLDEnter_Click()
    Cells(xrow, 6).Value = txtEl.Text
    Rows("4:110").RowHeight = 15.75
    ActiveCell.WrapText = True
    MsgBox "Your entry has been updated.", vbInformation, "Updated"
    Unload Me
    
End Sub
/CODE]

I had tried various options on text wrapping both with code as above and by general formatting and all that happened was it extended the cell row height to accommodate the text, hence adding in the Rowheight variable above.

hopefully this helps

Thanks again

Paul
 
Upvote 0
Paul

Is the whole string going in the cell but all you are seeing is the end of it?
 
Upvote 0
Hi Norie - that's it exactly - coding wise everything works fine just all the users sees in the cell is the last few words
 
Upvote 0
Hi sorry to be a pain but is there any further advice that can be offered on my post please?

Thank you.
 
Upvote 0
What happens if you remove this?
Code:
ActiveCell.WrapText = True
 
Upvote 0
Hi Norie, I tried that already but it didn't make any difference
 
Upvote 0
Is there any code elsewhere in the workbook that could be being triggered when you put the value from the textbox into a cell?
 
Upvote 0
I don't think so but I will have a check back on some of the earlier versions of this workbook saved as changes were made to the coding at different points to see if it works at all at any point and then I can look at the code that was added after this.

The complete subs in relation to my original post are as follows

code to allow right click event


Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Set Target = Target.Cells(1, 1)
    If Not Intersect(Target, Range("D4:D110")) Is Nothing Then
        Application.EnableEvents = False
        Application.Dialogs(xlDialogPatterns).Show
        Cancel = True
    End If
Set Target = Target.Cells(1, 1)
    If Not Intersect(Target, Range("V4:V110")) Is Nothing Then
        Cancel = True
        xrow = Target.Row
        strCellText = Target.Value
        UserForm1.Show
    End If

    Set Target = Target.Cells(1, 1)
    If Not Intersect(Target, Range("F4:F110")) Is Nothing Then
        Cancel = True
        xrow = Target.Row
        strCellText = Target.Value
        frmEL.Show
    End If
    Set Target = Target.Cells(1, 1)
    If Not Intersect(Target, Range("G4:G110")) Is Nothing Then
        Cancel = True
        xrow = Target.Row
        strCellText = Target.Value
        frmET.Show
    End If
    Application.EnableEvents = True
End Sub


Code for the commandbutton on the relevant user form

Code:
Private Sub CmdLDEnter_Click()
    Cells(xrow, 6).Value = txtEl.Text
    Rows("4:110").RowHeight = 15.75
    ActiveCell.WrapText = True
    MsgBox "Your entry has been updated.", vbInformation, "Updated"
    Unload Me
    
End Sub

I will check and post back the results

Thanks for the advice !
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,949
Members
448,534
Latest member
benefuexx

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