Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AJL AJL is offline
external usenet poster
 
Posts: 18
Default Copy from a Cell to a text box.

Hello,
I am trying to copy and paste the text returned by several vlookup formulas
to a text box. The amount of text returned to the cells is quite large.
When I set the text box equal to one of the cells, only a portion of the text
appears in the text box. When I set it equal to a range of cells I get
nothing. Is it possible to generate a macro that will copy and paste large
amounts of text that result from numerous equations into a text box?
Thanks.

-Alan Lueke
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 81
Default Copy from a Cell to a text box.

Alan -
This simple code will get you started. Range A1:A5 is where the data
is stored. Modify this to suit your needs. You may also need to
change the text box name if you have multiple text boxes on the sheet.

Sub AddTextToBox()

Dim strTextBox As String

For Each cell In Range("A1:A5")
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

End Sub

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
Hello,
I am trying to copy and paste the text returned by several vlookup formulas
to a text box. The amount of text returned to the cells is quite large.
When I set the text box equal to one of the cells, only a portion of the text
appears in the text box. When I set it equal to a range of cells I get
nothing. Is it possible to generate a macro that will copy and paste large
amounts of text that result from numerous equations into a text box?
Thanks.

-Alan Lueke


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,311
Default Copy from a Cell to a text box.

I believe you'll need to set the properties of your text box. In design
mode, right-click on your text box and select Properties. Then, Enable
WordWrap and Multi Line.

HTH,
Paul


"AJL" wrote in message
...
Hello,
I am trying to copy and paste the text returned by several vlookup
formulas
to a text box. The amount of text returned to the cells is quite large.
When I set the text box equal to one of the cells, only a portion of the
text
appears in the text box. When I set it equal to a range of cells I get
nothing. Is it possible to generate a macro that will copy and paste
large
amounts of text that result from numerous equations into a text box?
Thanks.

-Alan Lueke



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AJL AJL is offline
external usenet poster
 
Posts: 18
Default Copy from a Cell to a text box.

I entered the macro script you gave me, changing the range to the appropriate
range that contains my vlookups returning text, and the name of the text box
to the correct box. I then assigned the macro to a button. Running the
macro however doesn't put the text in the box, it gives no errors either, it
seems like nothing is happening.

"John Michl" wrote:

Alan -
This simple code will get you started. Range A1:A5 is where the data
is stored. Modify this to suit your needs. You may also need to
change the text box name if you have multiple text boxes on the sheet.

Sub AddTextToBox()

Dim strTextBox As String

For Each cell In Range("A1:A5")
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

End Sub

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
Hello,
I am trying to copy and paste the text returned by several vlookup formulas
to a text box. The amount of text returned to the cells is quite large.
When I set the text box equal to one of the cells, only a portion of the text
appears in the text box. When I set it equal to a range of cells I get
nothing. Is it possible to generate a macro that will copy and paste large
amounts of text that result from numerous equations into a text box?
Thanks.

-Alan Lueke



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 81
Default Copy from a Cell to a text box.

Add the message boxes below and it should help you find where the
problem is. If Box 3 shows nothing after the = sign the problem then
is with your code between the For and Next statements. If Box 3 does
have a result, then the problem is with the with Shapes statement which
may indicate that you are using a control rather than a shape.

- John

Sub AddTextToBox()
Dim strTextBox As String
MsgBox "Box 1. Starting macro."

For Each cell In Range("A1:A5")
MsgBox "Box 2. " & cell.Address & " - contents = " & cell.value
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

MsgBox "Box 3. Contents of strTextBox = " & strTextBox

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

MsgBox "Box 4. Done."

End Sub



AJL wrote:
I entered the macro script you gave me, changing the range to the appropriate
range that contains my vlookups returning text, and the name of the text box
to the correct box. I then assigned the macro to a button. Running the
macro however doesn't put the text in the box, it gives no errors either, it
seems like nothing is happening.

"John Michl" wrote:

Alan -
This simple code will get you started. Range A1:A5 is where the data
is stored. Modify this to suit your needs. You may also need to
change the text box name if you have multiple text boxes on the sheet.

Sub AddTextToBox()

Dim strTextBox As String

For Each cell In Range("A1:A5")
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

End Sub

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
Hello,
I am trying to copy and paste the text returned by several vlookup formulas
to a text box. The amount of text returned to the cells is quite large.
When I set the text box equal to one of the cells, only a portion of the text
appears in the text box. When I set it equal to a range of cells I get
nothing. Is it possible to generate a macro that will copy and paste large
amounts of text that result from numerous equations into a text box?
Thanks.

-Alan Lueke






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AJL AJL is offline
external usenet poster
 
Posts: 18
Default Copy from a Cell to a text box.

I put the message boxes in, and the macro does run to completion. The text
however, still does not appear in the text box, and it is indeed a shape. I
noticed in the message boxes, some of the text returned in the cells is being
truncated when selected. Is it possible that I have exceded some sort of
character limit that is preventing my text from pasting into the text box?
if so, is it possible to overcome that limit? There is definately more text
retuning from the vlookup and it is present in the cell. When I print my
strTextBox buffer however, only a portion appears.

"John Michl" wrote:

Add the message boxes below and it should help you find where the
problem is. If Box 3 shows nothing after the = sign the problem then
is with your code between the For and Next statements. If Box 3 does
have a result, then the problem is with the with Shapes statement which
may indicate that you are using a control rather than a shape.

- John

Sub AddTextToBox()
Dim strTextBox As String
MsgBox "Box 1. Starting macro."

For Each cell In Range("A1:A5")
MsgBox "Box 2. " & cell.Address & " - contents = " & cell.value
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

MsgBox "Box 3. Contents of strTextBox = " & strTextBox

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

MsgBox "Box 4. Done."

End Sub



AJL wrote:
I entered the macro script you gave me, changing the range to the appropriate
range that contains my vlookups returning text, and the name of the text box
to the correct box. I then assigned the macro to a button. Running the
macro however doesn't put the text in the box, it gives no errors either, it
seems like nothing is happening.

"John Michl" wrote:

Alan -
This simple code will get you started. Range A1:A5 is where the data
is stored. Modify this to suit your needs. You may also need to
change the text box name if you have multiple text boxes on the sheet.

Sub AddTextToBox()

Dim strTextBox As String

For Each cell In Range("A1:A5")
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

End Sub

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
Hello,
I am trying to copy and paste the text returned by several vlookup formulas
to a text box. The amount of text returned to the cells is quite large.
When I set the text box equal to one of the cells, only a portion of the text
appears in the text box. When I set it equal to a range of cells I get
nothing. Is it possible to generate a macro that will copy and paste large
amounts of text that result from numerous equations into a text box?
Thanks.

-Alan Lueke




  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 81
Default Copy from a Cell to a text box.

Yes, there are limites (255 characters, I think) but some work arounds.
I used this article awhile back to solve similar problems.

http://support.microsoft.com/default.aspx?kbid=148815

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
I put the message boxes in, and the macro does run to completion. The text
however, still does not appear in the text box, and it is indeed a shape. I
noticed in the message boxes, some of the text returned in the cells is being
truncated when selected. Is it possible that I have exceded some sort of
character limit that is preventing my text from pasting into the text box?
if so, is it possible to overcome that limit? There is definately more text
retuning from the vlookup and it is present in the cell. When I print my
strTextBox buffer however, only a portion appears.

"John Michl" wrote:

Add the message boxes below and it should help you find where the
problem is. If Box 3 shows nothing after the = sign the problem then
is with your code between the For and Next statements. If Box 3 does
have a result, then the problem is with the with Shapes statement which
may indicate that you are using a control rather than a shape.

- John

Sub AddTextToBox()
Dim strTextBox As String
MsgBox "Box 1. Starting macro."

For Each cell In Range("A1:A5")
MsgBox "Box 2. " & cell.Address & " - contents = " & cell.value
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

MsgBox "Box 3. Contents of strTextBox = " & strTextBox

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

MsgBox "Box 4. Done."

End Sub



AJL wrote:
I entered the macro script you gave me, changing the range to the appropriate
range that contains my vlookups returning text, and the name of the text box
to the correct box. I then assigned the macro to a button. Running the
macro however doesn't put the text in the box, it gives no errors either, it
seems like nothing is happening.

"John Michl" wrote:

Alan -
This simple code will get you started. Range A1:A5 is where the data
is stored. Modify this to suit your needs. You may also need to
change the text box name if you have multiple text boxes on the sheet.

Sub AddTextToBox()

Dim strTextBox As String

For Each cell In Range("A1:A5")
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

End Sub

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
Hello,
I am trying to copy and paste the text returned by several vlookup formulas
to a text box. The amount of text returned to the cells is quite large.
When I set the text box equal to one of the cells, only a portion of the text
appears in the text box. When I set it equal to a range of cells I get
nothing. Is it possible to generate a macro that will copy and paste large
amounts of text that result from numerous equations into a text box?
Thanks.

-Alan Lueke





  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,311
Default Copy from a Cell to a text box.

I think John is correct on the character limit of a cell being 255 before
the text begins to appear truncated. The text is still in the cell, but all
of it is not seen. However, I have had no problems with getting a textbox
to display all of the text when linking that cell. I tested this on a cell
that contains 2,136 characters. Though the text in the cell appears
trucated, the textbox displays all of the text as long as the textbox is
large enough and the properties are set for MultiLine and WordWrap.

To see if the issue has anything to do with the fact that the text is
formula generated, you might to cut and PasteSpecial (Values Only) to
another cell and see if linking to that cell changes anything.

Regards,
Paul

"AJL" wrote in message
...
I put the message boxes in, and the macro does run to completion. The text
however, still does not appear in the text box, and it is indeed a shape.
I
noticed in the message boxes, some of the text returned in the cells is
being
truncated when selected. Is it possible that I have exceded some sort of
character limit that is preventing my text from pasting into the text box?
if so, is it possible to overcome that limit? There is definately more
text
retuning from the vlookup and it is present in the cell. When I print my
strTextBox buffer however, only a portion appears.

"John Michl" wrote:

Add the message boxes below and it should help you find where the
problem is. If Box 3 shows nothing after the = sign the problem then
is with your code between the For and Next statements. If Box 3 does
have a result, then the problem is with the with Shapes statement which
may indicate that you are using a control rather than a shape.

- John

Sub AddTextToBox()
Dim strTextBox As String
MsgBox "Box 1. Starting macro."

For Each cell In Range("A1:A5")
MsgBox "Box 2. " & cell.Address & " - contents = " & cell.value
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

MsgBox "Box 3. Contents of strTextBox = " & strTextBox

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

MsgBox "Box 4. Done."

End Sub



AJL wrote:
I entered the macro script you gave me, changing the range to the
appropriate
range that contains my vlookups returning text, and the name of the
text box
to the correct box. I then assigned the macro to a button. Running
the
macro however doesn't put the text in the box, it gives no errors
either, it
seems like nothing is happening.

"John Michl" wrote:

Alan -
This simple code will get you started. Range A1:A5 is where the data
is stored. Modify this to suit your needs. You may also need to
change the text box name if you have multiple text boxes on the
sheet.

Sub AddTextToBox()

Dim strTextBox As String

For Each cell In Range("A1:A5")
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

End Sub

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
Hello,
I am trying to copy and paste the text returned by several vlookup
formulas
to a text box. The amount of text returned to the cells is quite
large.
When I set the text box equal to one of the cells, only a portion
of the text
appears in the text box. When I set it equal to a range of cells I
get
nothing. Is it possible to generate a macro that will copy and
paste large
amounts of text that result from numerous equations into a text
box?
Thanks.

-Alan Lueke






  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AJL AJL is offline
external usenet poster
 
Posts: 18
Default Copy from a Cell to a text box.

The code in the article you sent seems like it should work. However, the
macro will insert the text fine if the text in the cell is less than 255
characters, but still leaves the text box blank for strings larger than 255.
Here is what I am using...

Sub Cell_Text_To_TextBox()

' Dimension the variables.
Dim txtBox1 As TextBox
Dim theRange As Range, cell As Range
Dim startPos As Integer
Set wks1 = Worksheets("Patient1")
' Set txtBox1 equal to the active sheet's TextBox object. You can
' replace the ordinal number with your text box name in quotes.
' For example: ActiveSheet.DrawingObjects("Text 1")
Set txtBox1 = wks1.DrawingObjects("Text Box 36")

' Set a range on the active sheet equal to the range object text
' that you are interested in copying to the text box.
Set theRange = ActiveSheet.Range("D42:D72")

'Set the starting position for the text.
startPos = 1

' Create a For-Each construct to loop through the cells in the range.
For Each cell In theRange

' Populate the textbox with the cell values using the Characters
' method.
' Note: Chr(10) can be used to add a new line in the textbox for
' each cell.
txtBox1.Characters(Start:=startPos, _
Length:=Len(cell.Value)).Text = cell.Value & Chr(10)
' Update the startPos variable to keep track of where the next
' string of text will begin in the textbox.
startPos = startPos + Len(cell.Value) + 1

Next cell
End Sub

"John Michl" wrote:

Yes, there are limites (255 characters, I think) but some work arounds.
I used this article awhile back to solve similar problems.

http://support.microsoft.com/default.aspx?kbid=148815

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
I put the message boxes in, and the macro does run to completion. The text
however, still does not appear in the text box, and it is indeed a shape. I
noticed in the message boxes, some of the text returned in the cells is being
truncated when selected. Is it possible that I have exceded some sort of
character limit that is preventing my text from pasting into the text box?
if so, is it possible to overcome that limit? There is definately more text
retuning from the vlookup and it is present in the cell. When I print my
strTextBox buffer however, only a portion appears.

"John Michl" wrote:

Add the message boxes below and it should help you find where the
problem is. If Box 3 shows nothing after the = sign the problem then
is with your code between the For and Next statements. If Box 3 does
have a result, then the problem is with the with Shapes statement which
may indicate that you are using a control rather than a shape.

- John

Sub AddTextToBox()
Dim strTextBox As String
MsgBox "Box 1. Starting macro."

For Each cell In Range("A1:A5")
MsgBox "Box 2. " & cell.Address & " - contents = " & cell.value
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

MsgBox "Box 3. Contents of strTextBox = " & strTextBox

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

MsgBox "Box 4. Done."

End Sub



AJL wrote:
I entered the macro script you gave me, changing the range to the appropriate
range that contains my vlookups returning text, and the name of the text box
to the correct box. I then assigned the macro to a button. Running the
macro however doesn't put the text in the box, it gives no errors either, it
seems like nothing is happening.

"John Michl" wrote:

Alan -
This simple code will get you started. Range A1:A5 is where the data
is stored. Modify this to suit your needs. You may also need to
change the text box name if you have multiple text boxes on the sheet.

Sub AddTextToBox()

Dim strTextBox As String

For Each cell In Range("A1:A5")
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

End Sub

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
Hello,
I am trying to copy and paste the text returned by several vlookup formulas
to a text box. The amount of text returned to the cells is quite large.
When I set the text box equal to one of the cells, only a portion of the text
appears in the text box. When I set it equal to a range of cells I get
nothing. Is it possible to generate a macro that will copy and paste large
amounts of text that result from numerous equations into a text box?
Thanks.

-Alan Lueke






  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AJL AJL is offline
external usenet poster
 
Posts: 18
Default Copy from a Cell to a text box.

I did get this solution to work, however, the text I need displayed exists in
multiple cells, depending on values entered in the sheet and the resulting
vlookup. I could not find a way to link a control text box to a range of
cells. :(

"PCLIVE" wrote:

I think John is correct on the character limit of a cell being 255 before
the text begins to appear truncated. The text is still in the cell, but all
of it is not seen. However, I have had no problems with getting a textbox
to display all of the text when linking that cell. I tested this on a cell
that contains 2,136 characters. Though the text in the cell appears
trucated, the textbox displays all of the text as long as the textbox is
large enough and the properties are set for MultiLine and WordWrap.

To see if the issue has anything to do with the fact that the text is
formula generated, you might to cut and PasteSpecial (Values Only) to
another cell and see if linking to that cell changes anything.

Regards,
Paul

"AJL" wrote in message
...
I put the message boxes in, and the macro does run to completion. The text
however, still does not appear in the text box, and it is indeed a shape.
I
noticed in the message boxes, some of the text returned in the cells is
being
truncated when selected. Is it possible that I have exceded some sort of
character limit that is preventing my text from pasting into the text box?
if so, is it possible to overcome that limit? There is definately more
text
retuning from the vlookup and it is present in the cell. When I print my
strTextBox buffer however, only a portion appears.

"John Michl" wrote:

Add the message boxes below and it should help you find where the
problem is. If Box 3 shows nothing after the = sign the problem then
is with your code between the For and Next statements. If Box 3 does
have a result, then the problem is with the with Shapes statement which
may indicate that you are using a control rather than a shape.

- John

Sub AddTextToBox()
Dim strTextBox As String
MsgBox "Box 1. Starting macro."

For Each cell In Range("A1:A5")
MsgBox "Box 2. " & cell.Address & " - contents = " & cell.value
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

MsgBox "Box 3. Contents of strTextBox = " & strTextBox

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

MsgBox "Box 4. Done."

End Sub



AJL wrote:
I entered the macro script you gave me, changing the range to the
appropriate
range that contains my vlookups returning text, and the name of the
text box
to the correct box. I then assigned the macro to a button. Running
the
macro however doesn't put the text in the box, it gives no errors
either, it
seems like nothing is happening.

"John Michl" wrote:

Alan -
This simple code will get you started. Range A1:A5 is where the data
is stored. Modify this to suit your needs. You may also need to
change the text box name if you have multiple text boxes on the
sheet.

Sub AddTextToBox()

Dim strTextBox As String

For Each cell In Range("A1:A5")
strTextBox = strTextBox & cell.Value & Chr(10)
Next cell

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
strTextBox

End Sub

- John
www.johnmichl.com/exceltips.htm

AJL wrote:
Hello,
I am trying to copy and paste the text returned by several vlookup
formulas
to a text box. The amount of text returned to the cells is quite
large.
When I set the text box equal to one of the cells, only a portion
of the text
appears in the text box. When I set it equal to a range of cells I
get
nothing. Is it possible to generate a macro that will copy and
paste large
amounts of text that result from numerous equations into a text
box?
Thanks.

-Alan Lueke







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy text from word with returns into one cell Carolyn Excel Discussion (Misc queries) 8 September 4th 06 11:16 PM
Text entries behaving like numbers jkiser Excel Discussion (Misc queries) 12 August 30th 06 09:29 PM
How can I copy cell formats in functions? Twitty Kitty Excel Worksheet Functions 3 July 24th 05 12:26 AM
How do I copy text from a cell into a comment? Catnip Excel Discussion (Misc queries) 1 May 27th 05 02:12 PM
Copy text from same cell on every sheet to title sheet? Jon Excel Discussion (Misc queries) 2 February 9th 05 04:11 PM


All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"