Reading textbox contents using VBA

  • I have a textbox on an Excel worksheet.


    As part of a large series of macros, I want to read the contents of the textbox (completed by the user) and store it elsewhere in a normal cell


    I cannot work out the code to read the contents of the textbox


    :roll:


    HELP!

  • Re: Reading textbox contents using VBA


    Hi there,


    Try this one ! Just make sure to type the right name of the textbox in the code before you run it.

    Code
    Sub ReadingTextbox()
        
        Range("H5").Value = ActiveSheet.TextBoxes("MyTextBox").Text
        
    End Sub


    Br,
    Pijay

  • Re: Reading textbox contents using VBA


    Thanks


    The problem I now have is that the textbox is a commentary, which can often contain >>255 characters. This works on screen, but does not work in my code:


    Code
    cells(1,1).value=activesheet.textboxes("commentary").text


    Any suggestions - I could do it by writing to files, but this way would be much easier (plus easier to understand by users)?? The cell contains 255 characters only (even though cells will accept much more and the source textbox contains much more)


    Help!

  • Re: Reading textbox contents using VBA


    Hi again,


    I'm sorry, I don't have a solution for that. But if you could go through with transfering the comment to more than one cell you could do something like this?



    I hope someone else can help you on this matter if this isn't it.


    Br,
    Pijay

  • Re: Reading textbox contents using VBA


    Hi,



  • Re: Reading textbox contents using VBA


    I am now having a problem writing the information saved in a cells (>>255 characters) into a text box



    doesnt appear to write anything to the text box (even though the array tmpcomm contains the text I need)


    HELP!!!!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!