Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Sheets("Rpt").Copy different results from running in macro than off excel menu??


Hi, thanks in advance for anyone who can help.

When I run the above command embedded in a macro it does the copy sheet
command sucessfully but loses the number format of the original.

When I use the Excel edit move or copy sheet to do the same thing it
preserves the number format (which is a custom format).

I really need to preserve the original number formats. Anyone have any
ideas?


--
tmbo
------------------------------------------------------------------------
tmbo's Profile: http://www.excelforum.com/member.php...o&userid=37214
View this thread: http://www.excelforum.com/showthread...hreadid=569306

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Sheets("Rpt").Copy different results from running in macro than offexcel menu??

I couldn't duplicate this in xl2003.

What version of excel are you using and what's the custom number format?

tmbo wrote:

Hi, thanks in advance for anyone who can help.

When I run the above command embedded in a macro it does the copy sheet
command sucessfully but loses the number format of the original.

When I use the Excel edit move or copy sheet to do the same thing it
preserves the number format (which is a custom format).

I really need to preserve the original number formats. Anyone have any
ideas?

--
tmbo
------------------------------------------------------------------------
tmbo's Profile: http://www.excelforum.com/member.php...o&userid=37214
View this thread: http://www.excelforum.com/showthread...hreadid=569306


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Sheets("Rpt").Copy different results from running in macro than off excel menu??


Hi Dave,

Thanks for the reply.

I am using 2003 and the number format I am using is:

_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)

So if you have a sheet with a custom number format as above and then
use

Edit move or copy sheet

with
To Book: (New Book)

and Create a copy ticked

It will keep the format. If at the same time you record the macro to do
that process and then play that macro it will lose the format...very
frustrating!!!

Hope you can help.

Thanks Tim


--
tmbo
------------------------------------------------------------------------
tmbo's Profile: http://www.excelforum.com/member.php...o&userid=37214
View this thread: http://www.excelforum.com/showthread...hreadid=569306

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Sheets("Rpt").Copy different results from running in macro than offexcel menu??

I still couldn't replicate it.

I used this code to test:

Option Explicit
Sub testme()

Dim wks As Worksheet
Set wks = Worksheets("sheet1")

With wks
.Range("a1").NumberFormat _
= "_(* #,##0_);_(* (#,##0);_(* "" - ""_);_(@_)"
Debug.Print "Befo " & .Range("A1").NumberFormat
.Copy
End With

Debug.Print "After: " & ActiveSheet.Range("a1").NumberFormat
End Sub

And pasting from the immediate window:

Befo _(* #,##0_);_(* (#,##0);_(* " - "_);_(@_)
After: _(* #,##0_);_(* (#,##0);_(* " - "_);_(@_)

And when I used .Move (instead of .Copy), I got this:

Befo _(* #,##0_);_(* (#,##0);_(* " - "_);_(@_)
After: _(* #,##0_);_(* (#,##0);_(* " - "_);_(@_)

I don't know if this has anything to do with your problem, but this formatting
is the same as my Accounting with 0 decimals and no currency symbol. Is there
anything special with your accounting format?

Are you using USA settings?

What happens if you try the code I used? How about with a brand new workbook?

(I don't have a guess why it wouldn't work for you.)



tmbo wrote:

Hi Dave,

Thanks for the reply.

I am using 2003 and the number format I am using is:

_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)

So if you have a sheet with a custom number format as above and then
use

Edit move or copy sheet

with
To Book: (New Book)

and Create a copy ticked

It will keep the format. If at the same time you record the macro to do
that process and then play that macro it will lose the format...very
frustrating!!!

Hope you can help.

Thanks Tim

--
tmbo
------------------------------------------------------------------------
tmbo's Profile: http://www.excelforum.com/member.php...o&userid=37214
View this thread: http://www.excelforum.com/showthread...hreadid=569306


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Sheets("Rpt").Copy different results from running in macro than off excel menu??


Hi Dave,

To replicate it perhaps create a new number format in your custom list
that is not included in the template used to open a new sheet.

Unfortunately the code didn't work.

I think the problem with what I am doing is that when the code runs
from the macro it opens a new worksheet from a template that doesn't
have the format as a custom format.

I have to post the spreadsheet out to many users so I don't think it is
practical to get everyone to change their templates.

Still it is strange that when I run the same command from the Excel
menu it doesn't lose the formatting...can't quite work that one out.

I wonder if there is some other way I can around it...?


Cheers

Tim


--
tmbo
------------------------------------------------------------------------
tmbo's Profile: http://www.excelforum.com/member.php...o&userid=37214
View this thread: http://www.excelforum.com/showthread...hreadid=569306



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Sheets("Rpt").Copy different results from running in macro than off excel menu??


Hi Dave,

I attached a spreadsheet with an example.

If you run the macro in the this workbook you should see it revert to
the minus signs.

Cheers

Tim


--
tmbo
------------------------------------------------------------------------
tmbo's Profile: http://www.excelforum.com/member.php...o&userid=37214
View this thread: http://www.excelforum.com/showthread...hreadid=569306

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Sheets("Rpt").Copy different results from running in macro than offexcel menu??

I don't connect through excelforum, so I don't see the attachment. And I don't
open attachments anyway.

tmbo wrote:

Hi Dave,

I attached a spreadsheet with an example.

If you run the macro in the this workbook you should see it revert to
the minus signs.

Cheers

Tim

--
tmbo
------------------------------------------------------------------------
tmbo's Profile: http://www.excelforum.com/member.php...o&userid=37214
View this thread: http://www.excelforum.com/showthread...hreadid=569306


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Sheets("Rpt").Copy different results from running in macro than offexcel menu??

I don't have another guess,

Sorry.

tmbo wrote:

Hi Dave,

To replicate it perhaps create a new number format in your custom list
that is not included in the template used to open a new sheet.

Unfortunately the code didn't work.

I think the problem with what I am doing is that when the code runs
from the macro it opens a new worksheet from a template that doesn't
have the format as a custom format.

I have to post the spreadsheet out to many users so I don't think it is
practical to get everyone to change their templates.

Still it is strange that when I run the same command from the Excel
menu it doesn't lose the formatting...can't quite work that one out.

I wonder if there is some other way I can around it...?

Cheers

Tim

--
tmbo
------------------------------------------------------------------------
tmbo's Profile: http://www.excelforum.com/member.php...o&userid=37214
View this thread: http://www.excelforum.com/showthread...hreadid=569306


--

Dave Peterson
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
Importing EXCEL Spreadsheets into ACCESS -- Macro or VBA? Excel Discussion (Misc queries) 0 July 12th 06 10:08 PM
Macro problem in Excel pd Excel Discussion (Misc queries) 2 March 14th 06 05:49 AM
excel 4.0 macro removal tool Sachin Shah Excel Discussion (Misc queries) 0 August 25th 05 04:17 AM
excel 4.0 macro remover tool Sachin Shah Excel Discussion (Misc queries) 0 August 25th 05 04:14 AM
Urgent Help Required on Excel Macro Problem Sachin Shah Excel Discussion (Misc queries) 1 August 17th 05 06:26 AM


All times are GMT +1. The time now is 06:55 PM.

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"