View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Karan Karan is offline
external usenet poster
 
Posts: 21
Default Complex Formatting of cell

Nopes, it doesn't.
"""String from RC[-5] """ is the same as trying to pass 3 strings.
The first one would be "", the second "String from RC[-5] " and the third
would be "" again.
I'm at my wits end!

Any further ideas?
Cheers, Karan


"Bob Phillips" wrote:

Does this do it

X = """String from RC[-5] """ & " ###0.0"
Y = "=RC[-11]"
ActiveCell.Formula = Y
ActiveCell.NumberFormat = X


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Karan" wrote in message
...
Hi Bob...thanks for this. However there is still one problem because of
which
this doesnot work.
The value of X here turns out to be "String ###0.0"....and this is not a
valid format. It has to be ""String" ###0.0"
I tried using Chr(34) instead of a " but that isn't working. This is what
I
did:

X = "Chr(34) String Chr(34)" & " ###0.0"
Y = "=RC[-11]"
ActiveCell.Formula = Y
Activecell.NumberFormat = X

Any idea how I could pass an " in the Number format?

"Bob Phillips" wrote:

X = "String from RC[-5] " & " ###0.0"
Y = "=RC[-11]"
ActiveCell.Formula = Y
Activecell.NumberFormat = X

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Karan" wrote in message
...
Using the format cell dialog box one can choose Custom Format and give
the
format as

"String" ###0.0

The end result is a cell which has a number and text (String) in it,
but
when you click on the contents of the cell you can only see the number
and
cannot see the text (as it is in the format)

However I don't want to to do this manually for each cell as the string
changes for each cell.

I'm trying to figure out how a macro could set a custom format of a
cell
to
something like "String from RC[-5]" ###0.0

Using something like
X = "String from RC[-5] " & " ###0.0"
Y = "=RC[-11]"
ActiveCell = format(Y, X)

ends up showing both the string and the number in the cell, instead of
having the string in the format and not in the cell.

How can one put define a custom number format with a variable "String"
in
the format?