Solved

EXCEL / VBA - Text Boxes and rectangles

Posted on 2002-04-17
2
280 Views
Last Modified: 2008-03-10
I'm after a bit of VBA to do the following:-

I need to extract text which has been entered into a Text Box on an Excel sheet and write it into a cell.

Also on the same sheet are rectangles in which text has been written.  I also need to extract this and write it to a cell.

The reason for this is a badly designed spreadsheet (not mine)which was mailed to hundreds of people for them to fill in some comments.  I now have been asked to collate the results.

Many thanks in advance...
0
Comment
Question by:toffee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
ture earned 100 total points
ID: 6948139
toffee,

The approach depends on what you mean by a "text box". Excel calls shapes (rectangles) with text for "text boxes" but also the textboxes that are usually put on forms to edit text fields.

The VBA procedure below shows you how to handle both types of textboxes.

Sub ReadFromTextBox()
  Dim tb As msforms.TextBox
  Dim sh As Shape
 
  Set tb = ActiveSheet.TextBox1
  Range("A1").Value = tb.Text
 
  Set sh = ActiveSheet.Shapes("Text Box 3")
  Range("A2").Value = sh.TextFrame.Characters.Text
End Sub

Ture Magnusson
Karlstad, Sweden
0
 

Author Comment

by:toffee
ID: 6948193
Excellent!!!

This is the bit which worked.  Many thanks.

Dim sh As Shape
Set sh = ActiveSheet.Shapes("Text Box 3")
Range("A2").Value = sh.TextFrame.Characters.Text

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question