+ Reply to Thread
Results 1 to 5 of 5

Simple Question: Select Text Box from Spreadsheet?

Hybrid View

  1. #1
    Registered User
    Join Date
    06-02-2005
    Posts
    9

    Simple Question: Select Text Box from Spreadsheet?

    I am stuck on what seems a very simple problem: I can't select a textbox that is in a spreadsheet.

    The textbox is called Text Box 125 (at least that's what appears in the top left corner, where it usually displays cell name like "J8").

    I want to delete this textbox if a cell is empty. My difficulty is in selecting the box. I have tried things like:

    TextBox125.Select

    TxtBox125.Select

    Text_Box_125.Select


    What am I doing wrong?
    Thanks!!

  2. #2
    George Nicholson
    Guest

    Re: Simple Question: Select Text Box from Spreadsheet?

    Excel ranges have a "select" method, Textboxes don't. You can, however
    approach it other ways:
    Me.TextBox125.Delete
    or
    ActiveSheet.Shapes("TextBox125").Delete

    HTH,
    --
    George Nicholson

    Remove 'Junk' from return address.


    "Lost!" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I am stuck on what seems a very simple problem: I can't select a textbox
    > that is in a spreadsheet.
    >
    > The textbox is called Text Box 125 (at least that's what appears in the
    > top left corner, where it usually displays cell name like "J8").
    >
    > I want to delete this textbox if a cell is empty. My difficulty is in
    > selecting the box. I have tried things like:
    >
    > TextBox125.Select
    >
    > TxtBox125.Select
    >
    > Text_Box_125.Select
    >
    >
    > What am I doing wrong?
    > Thanks!!
    >
    >
    > --
    > Lost!
    > ------------------------------------------------------------------------
    > Lost!'s Profile:
    > http://www.excelforum.com/member.php...o&userid=23990
    > View this thread: http://www.excelforum.com/showthread...hreadid=377116
    >




  3. #3
    Charlie
    Guest

    RE: Simple Question: Select Text Box from Spreadsheet?

    You are asking about selecting the textbox, which is one thing, and deleting
    it if a cell is empty. I'm not sure exactly what it is you want to do but
    I'll do my best to describe how to do these things. To "select" the textbox
    I presume you mean you don't want the cursor to go there to type in
    something. You need to be in design mode.

    On the menu bar do View-->Toolbars-->Control Toolbox. When the window opens
    click on the button with the blue triangle and pencil. Now you can click on
    the textbox to select it. Press the Delete key to permanently delete the
    textbox.

    If this is not what you want to do, maybe you mean you want to hide the
    textbox (make it invisible) when a particular cell is empty. In the
    Worksheet_Change sub you can do something like this:

    TextBox125.Visible = Range("A1").Text <> ""


    "Lost!" wrote:

    >
    > I am stuck on what seems a very simple problem: I can't select a textbox
    > that is in a spreadsheet.
    >
    > The textbox is called Text Box 125 (at least that's what appears in the
    > top left corner, where it usually displays cell name like "J8").
    >
    > I want to delete this textbox if a cell is empty. My difficulty is in
    > selecting the box. I have tried things like:
    >
    > TextBox125.Select
    >
    > TxtBox125.Select
    >
    > Text_Box_125.Select
    >
    >
    > What am I doing wrong?
    > Thanks!!
    >
    >
    > --
    > Lost!
    > ------------------------------------------------------------------------
    > Lost!'s Profile: http://www.excelforum.com/member.php...o&userid=23990
    > View this thread: http://www.excelforum.com/showthread...hreadid=377116
    >
    >


  4. #4
    Registered User
    Join Date
    06-02-2005
    Posts
    9

    Clarification

    Thanks very much for the replies. First of all, I should mention that I am using Excel 2000.

    I was unclear. When I said I want to 'select' the box, I meant I want it to appear is if I had clicked on the border of the box and it was selected so that I could press the delete key and get rid of the box. I didn't mean that I want to have the cursor appear in the textbox itself. The only reason I want to select the box is to delete it after, so if this step can be skipped (as it appears from your replies), great!

    Also, I want to make it clear that the textbox to be deleted (or hidden) is in one of the tabs of my spreadsheet. It is NOT in VBA. The textboxes on my userforms are completely separate from the ones on the spreadsheet. These textboxes were added by someone else because she wanted it formatted differently.

    Unfortunately, neither of these solutions worked for me. I must be putting the code in the wrong place.

    When I tried the "TextBox125.Visible = Range("A1").Text <> """ in the Worksheet_Change Sub, I got an error.

    Also, I can't seem to get the "ActiveSheet.Shapes("TextBox125").Delete " code to work. I am trying to put it in the code that activates upon clicking a command button.

    Thanks!!

    P.S. Let me add that hiding the box is preferable to deleting it.
    Last edited by Lost!; 06-07-2005 at 02:41 PM.

  5. #5
    Charlie
    Guest

    Re: Simple Question: Select Text Box from Spreadsheet?


    "Lost!" wrote:

    > I was unclear. When I said I want to 'select' the box, I meant I want
    > it to appear is if I had clicked on the border of the box and it was
    > selected so that I could press the delete key and get rid of the box.


    That's what I thought you meant. You need to be in Design Mode to select
    the textbox as you mention. Then click on the textbox and press the delete
    key. George's method should work too, but you may need to specify the sheet
    by name like this:

    Sheets("Sheet1").Shapes("TextBox125").Delete

    But if you aren't creating and deleting controls on-the-fly, just going into
    Design Mode to get rid of it is easiest. The only way I know to get into
    Design Mode is through the View menu. View-->Toolbars-->Control Toolbox.
    There should be a button with a blue triangle to toggle in and out of Design
    Mode.



+ 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