+ Reply to Thread
Results 1 to 7 of 7

Tbox text copy to a cell macro

  1. #1
    Registered User
    Join Date
    08-10-2009
    Location
    Tallinn, Estonia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Tbox text copy to a cell macro

    Hi,

    I tried to read this and other forums but couldn’t find the answered I was looking for. I am awful at writing macros so I tried to record a macro that would copy text from sheet 1 text box 2 to a sheet 2 cell. I recorded a macro but it doesn’t work. The macro does not select the text box I want it to select.

    I also read that something like this should work:

    Sheets("Sheet1").TextBox2.Text = Sheets("Alg"). Range("ED5").Value

    But it doesn’t.

    Can someone please write me a macro or correct the one above this so that it would copy Text Box 2 content from sheet 1 to Sheet “Alg” cell ED5.

    Thank you
    Last edited by DaVihm; 04-12-2013 at 02:11 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Tbox text copy to a cell macro

    Try this...

    Sheets("Alg").Range("ED5").Value = Sheets("Sheet1").TextBox2.Text

  3. #3
    Registered User
    Join Date
    08-10-2009
    Location
    Tallinn, Estonia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Tbox text copy to a cell macro

    I ran this: Sub Kopeeri_text()
    '
    ' Kopeeri_text Macro
    '

    '
    Sheets("Alg").Range("ED5").Value = Sheets("Sheet1").TextBox2.Text

    End Sub

    and it gave me an error 438 "Object doesn't support this property or method"


  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Tbox text copy to a cell macro

    Your macro is correct as long as you have a text box named TextBox2 located on Sheet1. I tested it and it worked for me.

  5. #5
    Registered User
    Join Date
    08-10-2009
    Location
    Tallinn, Estonia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Tbox text copy to a cell macro

    The name is "Text Box 2" it has spaces in its name.If i write the name with spaces or " " or _ it still wont work. What should i use to fill the spaces in?

    Thank you

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Tbox text copy to a cell macro

    There are two types of textboxes. The ActiveX-type from the Control Toolbox toolbar and the Drawing Object type (or Shapes-type) from the Drawing toolbar. I assumed you used the ActiveX type because you originally referred to TextBox2 and that's the naming convention (no spaces) used for that type.

    This will get the text from the Drawing object type textbox.
    Sheets("Alg").Range("ED5").Value = Sheets("Sheet1").Shapes("Text Box 2").DrawingObject.Text

  7. #7
    Registered User
    Join Date
    08-10-2009
    Location
    Tallinn, Estonia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Tbox text copy to a cell macro

    Thank you AlphaFrog!

    The drawing object worked. I diden't know that there are two text boxes. I wrote it in one as i read a macro from another forum an i assumed that you had to skip the blanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1