VBA for Excel03 not working for Excel00

  • Thread starter Thread starter tjb
  • Start date Start date
T

tjb

I have some code that was written (with alot of help from
you all) that takes advantage of a feature in Excel 2003
that doesn't exist in Excel 2000. Many of my users still
have Excel 2000 but are slowly converting to Excel 2003.

Here's the problematic code:

Worksheets("Request Form").Unprotect Password:="password"

....other stuff in between...

Worksheets("Request Form").Protect Password:="password",
AllowFormattingCells:=True

As I'm sure you all know, Excel 2000 doesn't let
you "conditionally" protect a sheet, so when I try to run
the above noted code in Excel 2000 it gives an error and,
even worse, it unlocks the sheet without relocking it.

Any ideas or suggestions?
 
Hi Tjb

Try this

It will check the Excel version

Sub test()
Worksheets("Request Form").Unprotect Password:="password"

'...other stuff in between...

If Val(Application.Version) > 9 Then
Worksheets("Request Form").Protect Password:="password", AllowFormattingCells:=True
Else
Worksheets("Request Form").Protect Password:="password"
End If
End Sub
 

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