Macro not working for other colleagues

Lucas46

New Member
Joined
Jun 19, 2024
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi,
I often create "sort" macros to sort entries in a certain order.
They work fine for me wherever I login for my work, at home, in the office, on different work stations. But when other colleagues open the file and click on the button I inserted, it comes up with an error code.
They do click on the "enable macros" message that pops up.
Does anyone know what that can be?
Any help appreciated :)
 
...I am not doing too good am I on my first post.
I'll get back with more info.
That's 2 out of 3, but you didn't answer the 3rd question!

Usually, when you get the error message, you will get an option to click a "Debug" button.
When you click that, it should highlight the offending line of code in yellow.
It would be very helpful to see, and to see all your code.

Also, did you confirm what version of Excel the users getting this error are using?
If they are using an older version than you, you may be using code that has new arguments that their versions do not have.
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Please see screenshot of error yellow highlighted code below.
Macro was created using the "Record Macro" tool.
Like I said, when I click on the button I inserted the macro runs fine for me, when my colleague opens the same file and clicks the button, she gets this message.
 

Attachments

  • Screenshot Macro error.png
    Screenshot Macro error.png
    62.8 KB · Views: 14
Upvote 0
I think that may be one of the things that changed in later versions of Excel.
So confirm what version of Excel the users who are getting the error are running.
 
Upvote 0
I think that may be one of the things that changed in later versions of Excel.
So confirm what version of Excel the users who are getting the error are running.
Where can I find the version information, I assumed we are all on the 365 version, but I also use the desktop application.
I am just thinking, if my colleague is still using her desktop (I drag my laptop everywhere and use a docking station) she might still have an older version on there, all our laptops have Microsoft 365 installed.
No, she also uses her laptop with 365 on it...
 
Upvote 0
Have them record the same sorting macro from their computer, and compare your VBA code, and see if there is any difference.
 
Upvote 0
I have just noticed that it looks like you are running it on the active sheet, however, the code is fixed to run on a sheet named: DATES

As not all of the ranges are qualified, to run this on a sheet named: DATES when DATES is not the active sheet you could try:
VBA Code:
Sub SORT_ss()
  Dim ws As Worksheet
  
  Set ws = Worksheets("DATES")
  
  With ws
    .Sort.SortFields.Clear
    .Sort.SortFields.Add2 .Range("D7:D400"), xlSortOnValues, xlAscending, xlSortNormal
    .Sort.SortFields.Add2 .Range("J7:J400"), xlSortOnValues, xlAscending, xlSortNormal
    With .Sort
      .SetRange ws.Range("A6:AZ400")
      .Header = xlYes
      .MatchCase = False
      .Orientation = xlTopToBottom
      .SortMethod = xlPinYin
      .Apply
    End With
  End With
End Sub

If you wanted it to work on ANY active sheet then you could change the line in the above from:
VBA Code:
Set ws = Worksheets("DATES")
To:
VBA Code:
Set ws = ActiveSheet
 
Upvote 0
You may want to have them try changing "Add2" in your code to "Add".
("Add2" was added in later versions of Excel).
 
Upvote 0
Another option that should work for all versions
VBA Code:
Sub Lucas()
   With Sheets("dates")
      .Range("A6:AZ400").Sort .Range("D6"), xlAscending, .Range("J6"), , xlAscending, , , xlYes
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,178
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top