Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Setting cell format based on format codes

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Setting cell format based on format codes

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Setting cell format based on format codes

I'm afraid I have no experience with international formatting issues, so I
can't address what you have said directly; however, it is my belief
(although I could be wrong) that if you use locally correct formatting
pattern strings in your cells, then the code I posted should work. I don't
know what to say beyond that. Perhaps someone with more international excel
experience will come along and add to my comments. It's the weekend, so the
number of volunteers answering questions is small right now; so I would say
if you don't hear anything by Tuesday, repost your question (mentioning the
international formatting angle) and someone should be able to answer it
then.

--
Rick (MVP - Excel)


"Hans Knudsen" wrote in message
...
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





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
Cell format for Canadian postal codes mmcstech Excel Discussion (Misc queries) 10 April 21st 23 09:01 PM
Conditiona format based on format of another cell Tami Excel Worksheet Functions 1 December 18th 09 04:48 AM
How do I shade a cell using custom number format codes. Magnanakaw Excel Discussion (Misc queries) 2 January 15th 09 09:44 AM
Setting a cell format based on a function operation scott56hannah Excel Programming 4 December 11th 07 10:10 PM
how do i format a cell based on format of a range of cells? Chris Hardick Excel Discussion (Misc queries) 2 April 3rd 06 08:54 AM


All times are GMT +1. The time now is 09:51 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"