View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Hans Knudsen Hans Knudsen is offline
external usenet poster
 
Posts: 36
Default Setting cell format based on format codes

Rick Rothstein
Thank you.
Yes you understood me correctly, but there are some problems, which I think
is due to the fact that my location is Denmarkand as you may (not) know we
use

.. (point) as thousand separator
, (comma) as decimal separator

For example, when I run your macro on cells with the folllowing formats:
#.##0,00 "kroner" and
#.##0 "kroner"
I get the results
1500,000 kroner

1500,0 kroner


Date formats: For day, mont and year we use "dd-mm-مممم" where I guess you
would use "dd-mm-yyyy", that is م instead of y. For example the code
"mmm-مم" becomes nov مم after running your macro on a cell containg a date
i November.

I did not think of all these problems when I asked the question., and I
wonder if it is somewhat too involved.

Hans





"Rick Rothstein" wrote in message
...
If I understand your request correctly, this macro should do what you
want...

Sub ApplyFormats()
Dim C As Range
For Each C In Range("G14:G36")
C.Offset(0, 2).NumberFormat = C.Value
Next
End Sub

--
Rick (MVP - Excel)


"Hans Knudsen" wrote in message
...
I have some format codes in G14:G36 like:
G14: #.##0..
G15: _(* #.##0_);_(* (#.##0);_(* "-"_);_(@_)
G16: "+45"## ## ## ##
etc.

and would like a macro that can take the format codes in G14:G36 and
create these formats in cells I14:I36.

Will someone help me?

Regards
Hans Knudsen