Search code examples
excelvbatextbox

Geting error at TextBoxes property (one codeline)


I am geting an error at this codeline:

BUTTON_PRESSED = 1 'example
var = CInt(Sheets("sheet1").TextBoxes("Title_" & BUTTON_PRESSED).Text)

im triying to get the content of the textbox named Title_1

what am i missing?


Solution

  • You cannot access the text box on your sheet directly, but you can try through the Shapes collection.
    Use the following:

    var = CInt(Sheets("sheet1").Shapes("Title_" & BUTTON_PRESSED).DrawingObject.Text)
    

    Make sure you have an integer value typed in this textbox.