Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
KMH KMH is offline
external usenet poster
 
Posts: 31
Default General number formats changing to Dates or Euros

What causes Excel 2007 to change general number formats from general to dates
or euros? How can I easily fix a big model that has lots of this occuring
all over it?

Thanks,
Ken
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default General number formats changing to Dates or Euros

You must be very careful about entering data. Even if a cell is formatted
general, entering something like 1/1 will cause to "re-format" as a Date.
--
Gary''s Student - gsnu200908


"KMH" wrote:

What causes Excel 2007 to change general number formats from general to dates
or euros? How can I easily fix a big model that has lots of this occuring
all over it?

Thanks,
Ken

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 269
Default General number formats changing to Dates or Euros

There is some kind of glitch some where deep in the bowels of Excel. I have
also had this happen and have scanned the discussion groups to find that I am
not the only one with this problem. (mine was also dates and Euros by the way)

some code like this can remove the formats
sub datefixer()
TgtWorkbookName = ActiveWorkbook.Name
For Each Sh In Workbooks(TgtWorkbookName).Worksheets
For Each Cell In Sh.UsedRange.Cells
If Cell.NumberFormat = "[$-409]d-mmm-yy;@" Then
Cell.NumberFormat = "General"
End if
Next Cell
Next Sh

end sub

Note that this fixes a specific format namely "[$-409]d-mmm-yy;@" which was
my bad date one that was showing up for me.
You can change it to correct other ones also. It take a while to run on big
workbooks

to find the exact coding for other bad formats just gather by directly
referencing the cell

badformat=Range("A2").NumberFormat

sub datefixer()
dim badformat as string
TgtWorkbookName = ActiveWorkbook.Name
badformat=Range("A2").NumberFormat
For Each Sh In Workbooks(TgtWorkbookName).Worksheets
For Each Cell In Sh.UsedRange.Cells
If Cell.NumberFormat = badformat Then
Cell.NumberFormat = "General"
End if
Next Cell
Next Sh

end sub

You can get a lot fancier and gather all the used formats and do some fancy
loopin to purge them, but this is simple and does the trick.

One caution, this will change all formats back to general (or whatever other
format you may want to change it to)

If there are dates you want to keep you would either need to code in
exceptions or put them back later

--
If this helps, please remember to click yes.


"KMH" wrote:

What causes Excel 2007 to change general number formats from general to dates
or euros? How can I easily fix a big model that has lots of this occuring
all over it?

Thanks,
Ken

  #4   Report Post  
Posted to microsoft.public.excel.misc
KMH KMH is offline
external usenet poster
 
Posts: 31
Default General number formats changing to Dates or Euros

Thanks Paul and Gary's Student.

I used a combination of your ways, but found another as well. Below changes
the default "Normal" Style back to General Number Format. So far this seems
to work.

Sub FixDefaultNumFormat()
ActiveWorkbook.Styles("Normal").NumberFormat = "General"
End Sub

Thanks again

"Paul C" wrote:

There is some kind of glitch some where deep in the bowels of Excel. I have
also had this happen and have scanned the discussion groups to find that I am
not the only one with this problem. (mine was also dates and Euros by the way)

some code like this can remove the formats
sub datefixer()
TgtWorkbookName = ActiveWorkbook.Name
For Each Sh In Workbooks(TgtWorkbookName).Worksheets
For Each Cell In Sh.UsedRange.Cells
If Cell.NumberFormat = "[$-409]d-mmm-yy;@" Then
Cell.NumberFormat = "General"
End if
Next Cell
Next Sh

end sub

Note that this fixes a specific format namely "[$-409]d-mmm-yy;@" which was
my bad date one that was showing up for me.
You can change it to correct other ones also. It take a while to run on big
workbooks

to find the exact coding for other bad formats just gather by directly
referencing the cell

badformat=Range("A2").NumberFormat

sub datefixer()
dim badformat as string
TgtWorkbookName = ActiveWorkbook.Name
badformat=Range("A2").NumberFormat
For Each Sh In Workbooks(TgtWorkbookName).Worksheets
For Each Cell In Sh.UsedRange.Cells
If Cell.NumberFormat = badformat Then
Cell.NumberFormat = "General"
End if
Next Cell
Next Sh

end sub

You can get a lot fancier and gather all the used formats and do some fancy
loopin to purge them, but this is simple and does the trick.

One caution, this will change all formats back to general (or whatever other
format you may want to change it to)

If there are dates you want to keep you would either need to code in
exceptions or put them back later

--
If this helps, please remember to click yes.


"KMH" wrote:

What causes Excel 2007 to change general number formats from general to dates
or euros? How can I easily fix a big model that has lots of this occuring
all over it?

Thanks,
Ken

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
all General formats of the workbook changed to date format suddenl Miri Excel Discussion (Misc queries) 1 May 26th 08 09:24 PM
all the general formats of the workbook suddenly changed to date. Miri Excel Discussion (Misc queries) 2 May 25th 08 12:23 PM
all the general formats suddenly replaced with date format. Miri Excel Discussion (Misc queries) 1 May 20th 08 12:47 PM
Changing Number Formats based upon value DaveyC Excel Discussion (Misc queries) 3 May 14th 08 08:20 PM
Changing number formats without rebuilding worksheet Joe Excel Discussion (Misc queries) 2 January 17th 07 04:54 PM


All times are GMT +1. The time now is 04:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"