Re: How do you find WHERE Excel splits your wrapped string?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Peter T:

OK, I’ve played around a lot with your code, but I have so many
questions I must stop for the moment.

(Answer only if inclined:)

1. First and foremost, what I really need is, not code but a simple
statement of whether what I want can be done or not.

Ideally I want a formula "=MyWrap(X)" where X can be a string *or* a
cell address of a string, which returns the string wrapped 'n
indented.

Your code’s great & does this in a Sub (which I executed via Tools /
Macros--I assume that was correct). But a Sub doesn’t “return” the
result; it “calculates” it in real time inputting it anew in a cell.
After which the original string--however you passed it into the Sub--
is gone, right? But I’ve got hundreds of cell references to strings,
and those strings can change.

2. I’ve been a heavy Excel user for years, and I’d never heard of a
TextBox. However, after making yours visible I certainly grasped it,
and why you’re using it--i.e. as a buffer to measure when my string
exceeds its width.

But if a TextBox is required because a cell or range *itself* has no
useful property that you can apply to string length calculation, then:
Why? Is Redmond’s answer “42”?

3. On a similar score, I must beg your indulgence by asking, possibly
again and possibly dumbly: how does "column autofit", which you've
mentioned at times, enter into my problem? I need to wrap strings in a
column whose width is fixed. I'm not trying to determine what "column
width" a string "requires".

If on the other hand you're suggesting column autofit to somehow help
determine where Excel splits a string when wrapping, then...well, how
would that work? But at this point it might be tangential to the
current thread.

4. In trying to run your code as a UDF, the TextBox seemed to get
created OK, but any attempt to set any TB properties failed and was
totally ignored. E.g. if TB.TextFrame.Characters.Text was, say, "abc",
then command TB.TextFrame.Characters.Text = "xyz" did nothing and the
value remained "abc". And the compiler or interpreter (whatever the
term is) failed to warn me about it.

Is this failure by any chance related to the use of a Function instead
of a Sub? I’ve often seen the statement that some things just can’t be
done in a function.

5. You’re sizing the TB 5 units narrower than the cell. Is that some
magical number? Or a fudge factor of some sort?

Thanks much again if you read this.

***
.



Relevant Pages

  • VB, implementing the high score within this code
    ... Private possibleAs String ... Private Function SolvePuzzleAs Boolean ... ' Calculates the possible values for all the cell ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Formulas containing hard coded values
    ... Dim R As Range, sdoit As String ... MsgBox "Cell contains hard codes" ... Dim Fml As String, LCtext As String ... For Each Rng In R.Precedents.Areas ...
    (microsoft.public.excel.programming)
  • Re: Marking points read for coordinates
    ... In "Private Sub GetCoordinates()" comment all the code between ... (ByVal lpClassName As String, ByVal lpWindowName As String) ... ' cell A1 which is the base for all object coordinates on a sheet. ... Dim chtObj As ChartObject ...
    (microsoft.public.excel.programming)
  • Re: Text formatted cells displaying numbers in scientific format
    ... When it 'sees' a large number it uses scientific format since ... I accept that Excel can't handle numbers greater than 15 digits and your ... string was 16 digits or more to be converted to a scientific value. ... It just doesn't display correctly in the cell (except after entering ...
    (microsoft.public.excel)
  • Re: Parsing and Counting Matches - My State Table.xls (0/1)
    ... ' Search for occurance in a Cell of a string found in a specific Cell ... ' Need nested loops to traverse both the Search Cell and the String Cells. ... Dim CellString As String 'Cell to search ... CellRow = 2 ' Initialize Cell Row ...
    (microsoft.public.excel)