Cell.interior.colorindex - does not work in Excel 97

  • Thread starter Thread starter Ian
  • Start date Start date
I

Ian

I have the following code in an excel 2000 spreadsheet:



Private Sub CommandButton1_Click()

For Each cell In Range("c5:H32")
cell.Interior.ColorIndex = 0
Next cell

End Sub




But it does not work in Excel 97.

Any ideas why? I get run time error 1004

Ian,
 
Hi Ian

0 not exist
White is colorindex -4142

Try this in 97
ActiveCell.Interior.ColorIndex = -4142
 
Hi Ian

0 not exist
White is colorindex -4142

Try this in 97
ActiveCell.Interior.ColorIndex = -4142


Sorry, Ron,

Still does not work.

Cheers,

Ian,
 
Is it working if you run the macro with Alt-F8 instead of
using the button
 
Ron & Ian.

xlAutomatic = -4105
xlNone = -4142

Font cannot be formatted with xlnone, colorindex 1-56 or xlAutomatic only.
But "No Fill" for interior is xlNone.

Regards,
Peter T
 
Is it working if you run the macro with Alt-F8 instead of
using the button


I hve put the code in a macro and run it with AltF8
and it does not work, does it does not show up n error.

Ian,
 
HIi Ian

I will setup a virtual pc with Excel 97 now to test it.
 
If you change the takefocusonclick property of the button to false
you don't see the 1004 error (bug in 97)

The code is working for me in Excel 97 as a sub and in the click event of the button

But if your colors are a result of Format >conditional formatting it is not working.
Is that true ?
 
Sorry folks - somehow I read you were changing font.
Must be going dyslexic!
 
If you change the takefocusonclick property of the button to false
you don't see the 1004 error (bug in 97)

The code is working for me in Excel 97 as a sub and in the click event of the button

But if your colors are a result of Format >conditional formatting it is not working.
Is that true ?

Thanks, Ron. That has sorted it !

It works perfect now.

Many thanks.

Ian,
 
You are welcome

You confused me with saying that the sub not work
I hve put the code in a macro and run it with AltF8
and it does not work, does it does not show up n error.
 

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

Back
Top