Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Object Error

Greetings,

When I run the macro below, everything works fine until I get to the .
NumberFormat line. Then I get an error message that says Object required.
What I am trying to do is remove any colors and erase the cells contents in
the range, and then set the format to numeric with commas and no zeros.

How can I make this work?

Thanks in advance for your help!

Ray

Sub ResetSheet()
Dim bclro As Long

Application.ScreenUpdating = False ' turn off screen updating
bclro = Cells(65536, 1).End(xlUp).row
With Range(Cells(30, 1), Cells(bclro, 55))
.Interior.ColorIndex = xlNone
.Delete
.NumberFormat = "#,##0"
End With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Object Error

Ray,

In your code, you've Deleted the cell in question, so then the
With statement is pointing at Nothing when you try to use the
NumberFormat property. Rather than use Delete, you probably want
to use Clear.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ray Batig" wrote in message
nk.net...
Greetings,

When I run the macro below, everything works fine until I get
to the .
NumberFormat line. Then I get an error message that says Object
required.
What I am trying to do is remove any colors and erase the cells
contents in
the range, and then set the format to numeric with commas and
no zeros.

How can I make this work?

Thanks in advance for your help!

Ray

Sub ResetSheet()
Dim bclro As Long

Application.ScreenUpdating = False ' turn off screen updating
bclro = Cells(65536, 1).End(xlUp).row
With Range(Cells(30, 1), Cells(bclro, 55))
.Interior.ColorIndex = xlNone
.Delete
.NumberFormat = "#,##0"
End With




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Object Error

Thanks Chip,

I used the recorder to set up the macro and pushed the delete key. Now I
know better....

Ray

Chip Pearson wrote in message
...
Ray,

In your code, you've Deleted the cell in question, so then the
With statement is pointing at Nothing when you try to use the
NumberFormat property. Rather than use Delete, you probably want
to use Clear.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ray Batig" wrote in message
nk.net...
Greetings,

When I run the macro below, everything works fine until I get
to the .
NumberFormat line. Then I get an error message that says Object
required.
What I am trying to do is remove any colors and erase the cells
contents in
the range, and then set the format to numeric with commas and
no zeros.

How can I make this work?

Thanks in advance for your help!

Ray

Sub ResetSheet()
Dim bclro As Long

Application.ScreenUpdating = False ' turn off screen updating
bclro = Cells(65536, 1).End(xlUp).row
With Range(Cells(30, 1), Cells(bclro, 55))
.Interior.ColorIndex = xlNone
.Delete
.NumberFormat = "#,##0"
End With






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Object Error

The macro recorder should emit a ClearContents command rather
than Delete. At least it does for me.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ray Batig" wrote in message
ink.net...
Thanks Chip,

I used the recorder to set up the macro and pushed the delete
key. Now I
know better....

Ray

Chip Pearson wrote in message
...
Ray,

In your code, you've Deleted the cell in question, so then the
With statement is pointing at Nothing when you try to use the
NumberFormat property. Rather than use Delete, you probably
want
to use Clear.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ray Batig" wrote in message
nk.net...
Greetings,

When I run the macro below, everything works fine until I
get
to the .
NumberFormat line. Then I get an error message that says
Object
required.
What I am trying to do is remove any colors and erase the
cells
contents in
the range, and then set the format to numeric with commas
and
no zeros.

How can I make this work?

Thanks in advance for your help!

Ray

Sub ResetSheet()
Dim bclro As Long

Application.ScreenUpdating = False ' turn off screen
updating
bclro = Cells(65536, 1).End(xlUp).row
With Range(Cells(30, 1), Cells(bclro, 55))
.Interior.ColorIndex = xlNone
.Delete
.NumberFormat = "#,##0"
End With








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
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM
Runtime Error 1004 -- Application Defined or Object Defined Error John[_51_] Excel Programming 3 September 4th 03 04:28 PM


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