Making XL 2002 Macro Backwarly compatible with Xl 97

  • Thread starter Thread starter jfb
  • Start date Start date
J

jfb

Hi,

I've been writing some simpe menus/macros in XL2002 but when I try to run
them in XL 97 it complains with runtime error 1004.

I only want to sort a spreadsheet by a given column and use the in-built
form feature for Data entry,

Here is a section of code.

Private Sub CommandButton3_Click()
Worksheets("Data").Range("A1:AZ5000").Sort _
Key1:=Worksheets("Data").Columns("P"), _
Header:=xlGuess
Worksheets("MainMenu").Activate
Worksheets("Data").ShowDataForm
Worksheets("Data").Range("A1:AZ5000").Sort _
Key1:=Worksheets("Data").Columns("H"), _
Header:=xlGuess
End Sub


It also complains about the range but I reckon I know how to fix that.

Any help is appreciated.

Thanks
JB
 
Try changing the .takefocusonclick property to false
show the control toolbox toolbar
click on the design mode icon
right click on your command button
choose properties
and look for .takefocusonclick

(it's a bug that was fixed in xl2k)

If you ever use a different control from the control toolbox toolbar that
doesn't have that .takefocusonclick property, you can add a line like:

activecell.activate

at the top of your procedure.

(Heck, you could do it here, too!)
 
Back
Top