MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Feb 18th, 2002, 10:19 AM   #1
dedawson
New Member
 
Join Date: Feb 2002
Location: Thousand Oaks, CA
Posts: 4
Default

I have a workbook with numerous sheets whose date cells are formatted m/d/yy. When I manually copy these sheets to a new workbook by right clicking the sheet's tabs and then selecting (new book) and Make a Copy, all is well. The dates in the new workbook remain formatted as m/d/yy. If I perform this same action via a VBA macro, the dates in the new workbook are formatted as m/d/yyyy.

But wait, it gets worse. I can manually change the m/d/yyyy formatting of the new workbook to m/d/yy. If I do this with a macro, however, the changes aren't maintained. In fact, if one steps through the macro and watches the screen, when the line of code to set the format of the date to m/d/yy is executed, the change in fact occurs. When the next line of code executes, the cells just changed immediately revert to m/d/yyyy. This also occurs when attempting to change the date format on the axes of charts. What in the world is going on?!

[ This Message was edited by: dedawson on 2002-02-18 09:20 ]

[ This Message was edited by: dedawson on 2002-02-18 09:20 ]
dedawson is offline   Reply With Quote
Old Feb 19th, 2002, 03:26 PM   #2
Damon Ostrander
MrExcel MVP
 
Damon Ostrander's Avatar
 
Join Date: Feb 2002
Location: Denver, Colorado USA
Posts: 4,014
Default

Hi David,

I just tried this and couldn't duplicate the problem with Excel 97. What version are you using? Perhaps it would help to post the VBA code you are using. I assumed you are setting the cell date formatting using the cell's NumberFormat property.


__________________
Keep Excelling.

Damon

VBAexpert Excel Consulting
(My other life: http://damonostrander.com )
Damon Ostrander is offline   Reply With Quote
Old Feb 19th, 2002, 03:42 PM   #3
dedawson
New Member
 
Join Date: Feb 2002
Location: Thousand Oaks, CA
Posts: 4
Default

Hi back to you Damon,

I'm running Excel 97 SR-2 on NT 4.0

Here's the code (I hope it unwraps at your end):

Windows("CPCI Test Proc Gen metrics B1 15 procs rev1.xls").Activate
Sheets(Array("OverallCharts", "CVSV", "CPISPI", "cscitestunsort", _
"CSCITestProcDevreal")).Select
Sheets(Array("OverallCharts", "CVSV", "CPISPI", "cscitestunsort", _
"CSCITestProcDevreal")).Copy Before:=Workbooks("Book1").Sheets(1)


Sheets(Array("OverallCharts", "CVSV", "CPISPI", "cscitestunsort", _
"CSCITestProcDevreal")).Select
Sheets(Array("OverallCharts", "CVSV", "CPISPI", "cscitestunsort", _
"CSCITestProcDevreal")).Copy
Sheets("cscitestunsort").Select
Sheets("cscitestunsort").Name = "CSCITestProcOverall"
Sheets("CSCITestProcDevreal").Select
Sheets("CSCITestProcDevreal").Name = "CSCITestProcDetails"
Sheets("OverallCharts").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(2).DataLabels.Select
Selection.NumberFormat = "0.0%"
ActiveChart.SeriesCollection(5).DataLabels.Select
Selection.NumberFormat = "0.0%"
ActiveChart.SeriesCollection(1).DataLabels.Select
Selection.NumberFormat = "0.0%"
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.NumberFormat = "0%"
Range("OverallCharts_Dates_To_Format").Select
Selection.NumberFormat = "m/d/yy"

Sheets("CVSV").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.NumberFormat = "m/d/yy"
Range("CVSV_Dates_To_Format").Select
Selection.NumberFormat = "m/d/yy"

Sheets("CPISPI").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.NumberFormat = "m/d/yy"
Range("CPISPI_Dates_To_Format").Select
Selection.NumberFormat = "m/d/yy"

Its these bottom two chunks that are having the problem.

One other item, this occurs on two different machines that I've run the code on.

If this still doesn't make sense and you're still interested in helping me sort it out, send me a number and I'll give you a call on my dime.

Thanks for your interest and help.

david

[ This Message was edited by: dedawson on 2002-02-19 14:44 ]

[ This Message was edited by: dedawson on 2002-02-19 15:16 ]
dedawson is offline   Reply With Quote
Old Feb 19th, 2002, 03:51 PM   #4
Jack in the UK
Board Regular
 
Join Date: Feb 2002
Posts: 3,064
Default

Hi

Try after the copy - code out so that the pasted data is selected and then paste as number format in simple code to text and d/m/y or as required.. This way Excel should do as you want..

HTH
Rdgs
==========
Jack
Jack in the UK is offline   Reply With Quote
Old Feb 19th, 2002, 04:09 PM   #5
dedawson
New Member
 
Join Date: Feb 2002
Location: Thousand Oaks, CA
Posts: 4
Default

Hi Jack,

Kind of late there isn't it?

I'm not certain I follow what you're telling me. What I did try at one point however, was that after the copy I had code that formatted the cells in question as Number, and then reformatted them to "m/d/yy". No help.

Is this what you were suggesting?

Thanks, but don't lose any sleep tonight.

david
dedawson is offline   Reply With Quote
Old Feb 19th, 2002, 04:18 PM   #6
Jack in the UK
Board Regular
 
Join Date: Feb 2002
Posts: 3,064
Default

Hi --

Yep very late mate 12PM ish i think all my post are very late- i sleep dreadfully i dream of Excel and sometimes Excel for a change!

Yes you correct, i just copy and with selection format as i want that way Excel is FORCED to do as i like .. same as :

="Jack says today is" & NOW() will fail needs to be formatted to text on the NOW() part

Copy and paste is always a chore..

Im tyred ////// but a pal Dave Hawley http://www.ozgrid.com has loads on goodies VBA CopySelect and destinations Paste in hard codes in one lines.. try having a look.. VBA Section and also see a little bit of everthing.

Say hi for me to Dave in Western Austraila if you see him.

HTH
Rdgs
==========
Jack ???

Jack in the UK is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 05:19 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes