VBA macro doesn't work on my Mac

damav78

New Member
Joined
Sep 29, 2024
Messages
39
Office Version
  1. 2021
Platform
  1. Windows
  2. MacOS
Hi I am using an excel file running a vba macro. The macro code works fine on my windows pc but it doesn't work on my Mac although I have enable all macros from excel preferences.
Anyone could help??
Thank you
 
@dermie_72 that link is about Visual Basic (VB) and Visual Studio not Visual Basic for Applications (VBA).
@damav78 you'll need to post your code before anyone can give an answer without guessing
 
Upvote 0
@dermie_72 that link is about Visual Basic (VB) and Visual Studio not Visual Basic for Applications (VBA).
@damav78 you'll need to post your code before anyone can give an answer without guessing
@MARK858 My understanding was that Macs use Visual Studios, which does not support visual basic. Im not a Mac user, so I checked with multiple sources before posting the link. If this is incorrent, sorry for misleading the thread.
 
Upvote 0
Visual Basic and Visual Basic for Applications are not the same, the question is about Visual Basic for Applications. Visual Basic for Applications runs on a Mac but there are some differences to the version that runs on Windows (in general some options don't exist), which is why the OP should post the code that they are using.
 
Last edited:
Upvote 0
Visual Basic and Visual Basic for Applications are not the same, the question is about Visual Basic for Applications. Visual Basic for Applications runs on a Mac but there are some differences to the version that runs on Windows (in general some options don't exist), which is why the OP should post the code that they are using.
Hi, and sorry for late response. This code was made by a user of this forum in order to help me.
The code is:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 6 Or Target.Column <> 2 Then Exit Sub
If Target <> "" Then
Range("R" & Target.Row).Value = Range("R" & Target.Row).Value
Range("T" & Target.Row).Value = Range("T" & Target.Row).Value
Else
Range("R" & Target.Row).Formula = "=ROUND((A" & Target.Row & "*$D$1),0)"
Range("T" & Target.Row).Formula = "=(L" & Target.Row & "-($D$3*$D$2))/$D$1"
End If
End Sub
 
Upvote 0
In my windows pc works fine, but when I transfer the file to my iMac it doesn't work
 
Upvote 0
There is nothing I can see in that code that looks Windows specific (can't test at the moment as don't have a Mac with me).
  • What module do you have the code in?
  • Is the macro firing (if not sure put a message box as the first line of the code and change the value in cell B8 manually and see if you get the message)? if it isn't try putting the file in a Trusted Location and change B8 again.
  • How did you "transfer the file"?
  • Do you get an Error message? if yes what exactly does it say
 
Last edited:
Upvote 0
There is nothing I can see in that code that looks Windows specific (can't test at the moment as don't have a Mac with me).
  • What module do you have the code in?
  • Is the macro firing (if not sure put a message box as the first line of the code and change the value in cell B8 manually and see if you get the message)? if it isn't try putting the file in a Trusted Location and change B8 again.
  • How did you "transfer the file"?
  • Do you get an Error message? if yes what exactly does it say
What do you mean in what module do I have the code? As I told you, this code was made by a user who help me in this forum. I have 0 knowledge on codes etc.
The purpose of the code is... when I select a predefined text from a dropdown list that I have create in B column (so the cell is not empty), to "lock" the current values that cells R and T have at that time.
Cells R and T changes values constantly because they are affected by values of other cells and formulas. So he made this code in order to lock the value regardless the values of other cells that are affect them. If I delete the text from dropdown list the formula I have on that cells return to normal.
I transfer the file between windows and Mac with file transfer from anydesk or I iCloud
I just noticed one thing... when I right click on my Mac the sheet that normally has the code, the window is empty!! I don't see the code written like in my windows pc.
When I try to save it I get this message:
Errors were detected while saving '/Users/User/Desktop/Filename.xlsm'. Microsoft Excel may be able to save the file by removing or repairing some features. To make the repairs in a new file, click Continue. To cancel saving the file, click Cancel.
 
Upvote 0
What do you mean in what module do I have the code? As I told you, this code was made by a user who help me in this forum. I have 0 knowledge on codes etc.
There are 4 main types of module a regular module where the majority of code goes, a worksheet module (where this code should go), a Workbook module and a Class module. Please note the way this is written seems very abrupt for a legitimate question by someone who is trying to help you.
I transfer the file between windows and Mac with file transfer from anydesk or I iCloud
If you have transferred it from iCloud then your macro's might be blocked on the file and might have triggered the "Errors were detected while saving" message, if you transferred from a desktop with a memory stick then it is unlikely to get blocked.
when I right click on my Mac the sheet that normally has the code, the window is empty!! I don't see the code written like in my windows pc
Then try copying and pasting the code (preferably via a text file) from the file on the Windows machine into the Sheet code window and test (btw this answers the question I asked about which module the code is in) and test.
Then reply to this post with what issues it shows.
 
Upvote 0

Forum statistics

Threads
1,226,771
Messages
6,192,918
Members
453,766
Latest member
Gskier

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