Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default macro to change number format of a highlighted range in Excel 2007

I was using the following macro to change the number format of a highlighted
range.

Selection.NumberFormat = "#,##0"

In Excel 97 and 2000 it was working fine. In Excel 2007 it is giving me the
following error message:

Run-time error '1004'
Unable to set the NumberProperty of the range class

I am stumped and haven't been able to find any documentation on this change.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default macro to change number format of a highlighted range in Excel 2007

Is the worksheet protected?



Lauren977 wrote:

I was using the following macro to change the number format of a highlighted
range.

Selection.NumberFormat = "#,##0"

In Excel 97 and 2000 it was working fine. In Excel 2007 it is giving me the
following error message:

Run-time error '1004'
Unable to set the NumberProperty of the range class

I am stumped and haven't been able to find any documentation on this change.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default macro to change number format of a highlighted range in Excel

Hi Dave,

Yes the worksheet is protected, but I am running a routine to remove the
protection. This routine is the same as in my other macros and is working
the

If ActiveSheet.Protect = True Then ActiveSheet.Unprotect Password:="percy"

Thanks for getting back to me quickly.

Lauren

"Dave Peterson" wrote:

Is the worksheet protected?



Lauren977 wrote:

I was using the following macro to change the number format of a highlighted
range.

Selection.NumberFormat = "#,##0"

In Excel 97 and 2000 it was working fine. In Excel 2007 it is giving me the
following error message:

Run-time error '1004'
Unable to set the NumberProperty of the range class

I am stumped and haven't been able to find any documentation on this change.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default macro to change number format of a highlighted range in Excel

If you want to check for protection, you should use something like:

With ActiveSheet
If .ProtectContents = True _
Or .ProtectDrawingObjects = True _
Or .ProtectScenarios = True Then
.Unprotect Password:="percy"
end if
end with

But I bet excel will forgive you if you just unprotect it without checking:

ActiveSheet.Unprotect Password:="percy"



Lauren977 wrote:

Hi Dave,

Yes the worksheet is protected, but I am running a routine to remove the
protection. This routine is the same as in my other macros and is working
the

If ActiveSheet.Protect = True Then ActiveSheet.Unprotect Password:="percy"

Thanks for getting back to me quickly.

Lauren

"Dave Peterson" wrote:

Is the worksheet protected?



Lauren977 wrote:

I was using the following macro to change the number format of a highlighted
range.

Selection.NumberFormat = "#,##0"

In Excel 97 and 2000 it was working fine. In Excel 2007 it is giving me the
following error message:

Run-time error '1004'
Unable to set the NumberProperty of the range class

I am stumped and haven't been able to find any documentation on this change.


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default macro to change number format of a highlighted range in Excel

Thanks Dave,

That works great! You have saved me a huge amount of trial and error.

Lauren

"Dave Peterson" wrote:

If you want to check for protection, you should use something like:

With ActiveSheet
If .ProtectContents = True _
Or .ProtectDrawingObjects = True _
Or .ProtectScenarios = True Then
.Unprotect Password:="percy"
end if
end with

But I bet excel will forgive you if you just unprotect it without checking:

ActiveSheet.Unprotect Password:="percy"



Lauren977 wrote:

Hi Dave,

Yes the worksheet is protected, but I am running a routine to remove the
protection. This routine is the same as in my other macros and is working
the

If ActiveSheet.Protect = True Then ActiveSheet.Unprotect Password:="percy"

Thanks for getting back to me quickly.

Lauren

"Dave Peterson" wrote:

Is the worksheet protected?



Lauren977 wrote:

I was using the following macro to change the number format of a highlighted
range.

Selection.NumberFormat = "#,##0"

In Excel 97 and 2000 it was working fine. In Excel 2007 it is giving me the
following error message:

Run-time error '1004'
Unable to set the NumberProperty of the range class

I am stumped and haven't been able to find any documentation on this change.

--

Dave Peterson


--

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
How do you change the default number format in Excel 2007? Gabe Excel Discussion (Misc queries) 1 July 29th 08 03:33 PM
How do I change background color of highlighted Excel range ? Jim Excel Discussion (Misc queries) 0 June 6th 08 07:59 PM
Excel 2007 Record Macro button in Developer tab is not highlighted Golfnjohn Excel Discussion (Misc queries) 0 April 30th 08 09:31 PM
*.csv format change if .xlt save as .csv in Excel 2007 Khayae Excel Discussion (Misc queries) 1 December 14th 07 12:54 PM
How to count the number of cells highlighted using Conditional Formatting feature present in Format Menu of Excel??? divya Excel Programming 3 November 1st 06 12:47 PM


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