ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Need VBA code to enter text into a textbox !!!! (https://www.excelbanter.com/excel-discussion-misc-queries/25092-need-vba-code-enter-text-into-textbox.html)

Art Ferdinand

Need VBA code to enter text into a textbox !!!!
 
Does anybody know one line of code that will allow me to
enter a number into a textbox on a worksheet.

when I record a macro I get..

Sheets("venn").Select
ActiveSheet.Shapes("Text Box 27").Select
Selection.Characters.Text = "123"

I thought this implies I could code this like so...

Dim sht as sheet
set sht = activesheet.shapes("Text Box 27")
sht.characters.text = "123"
set sht = nothing

But this does not work !! what is the correct way of
doing this ?


Dave Peterson

How about:

Option Explicit
Sub testme()

Dim sht As Worksheet
Dim TBox As TextBox

Set sht = ActiveSheet
Set TBox = sht.TextBoxes("Text Box 27")

TBox.Characters.Text = "123"

Set sht = Nothing
Set TBox = Nothing

End Sub



Art Ferdinand wrote:

Does anybody know one line of code that will allow me to
enter a number into a textbox on a worksheet.

when I record a macro I get..

Sheets("venn").Select
ActiveSheet.Shapes("Text Box 27").Select
Selection.Characters.Text = "123"

I thought this implies I could code this like so...

Dim sht as sheet
set sht = activesheet.shapes("Text Box 27")
sht.characters.text = "123"
set sht = nothing

But this does not work !! what is the correct way of
doing this ?


--

Dave Peterson


All times are GMT +1. The time now is 07:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com