Runtime Error '1004'

S

slingsh0t

I'm running some code that declares rCell as a Range and steps through
a sheet using
For Each rCell in ActiveSheet.UsedRange

I encountered runtime error 1004, Unable to set HorizontalAlignment
property of the Range class.

Any thoughts as to why this is happening? Thanks!
 
M

Mangus Pyke

I'm running some code that declares rCell as a Range and steps through
a sheet using
For Each rCell in ActiveSheet.UsedRange

I encountered runtime error 1004, Unable to set HorizontalAlignment
property of the Range class.

Any thoughts as to why this is happening? Thanks!

I'm going to take a blind stab, solely because I'm too tired to go
write the code to check it..

Is it possible you need to select a cell or a range prior to using
that?

MP-
 
S

slingsh0t

Hi, Mangus-
Thanks for your response. Here's the long version of the story: as you
may know Excel can generate a "Too many cell formats" error in a
formatting-intensive sprdsht. I've written some code to go thru the
back office tabs of this workbook and reset formats to generic.

Can't explain why, but when I closed Excel and reopened the same
workbook the code runs fine. And you're right, it's too late and I'm
too tired to fuss with it any longer. I'm willing to chalk it up to
some kind of memory... uh... flux capacitor problem.

Thanks again for your come-back!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top