Duke,
Thanks for the help. But this is not what I'm looking for.
I'm looking for a Macro that does the same as the following windows process:
Click on a cell and click on "Format cells", then on custom format category.
In the type the custom format is "String" ###0.0.
What I'm trying to achieve is that the "String" should be a variable. The
end result of such a format is a cell which displays a number along with a
string. However if you click on the cell, it only has a number as a value.
Hence you can add/ subtract such cells even though it has a number and a
string.
For example the string could be something like "Kisses". In such a cell if
you put a number 10, then it will show up as "10 Kisses" in the cell. You can
format many cells and then add all cells to get a sum of all kisses
Cheers, Karan
"Duke Carey" wrote:
> from the Help file
>
> Worksheets("Sheet1").Range("A17").NumberFormat = "General"
> Worksheets("Sheet1").Rows(1).NumberFormat = "hh:mm:ss"
> Worksheets("Sheet1").Columns("C"). _
> NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
>
>
>
> "Karan" wrote:
>
> > 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?