Forum Discussion
Can you guys review this code?
JKPieterse so i found this on website;
#If Mac Then
[Mac specific code here]
#Else
[Windows specific code here]
#End If
End sub
i wrote my windows code between the windows and #endif line. Now what i didnt understand is when i run this code workbook close but not excel. before writing this code thw whole excel file closed. what can i add here to close the whole excel file and not just the workbook? i have searched on the internett to find out what #endif is, and found nothing. could you explain it and if i need to write anything under the #endif or not?
Thanks
For the code snippet you posted:
If run on a Mac, ONLY the bit between "#If Mac Then" and "#Else" is compiled and run.
If run on a Windows, ONLY the bit between "#Else" and "#End If" is compiled and run.
- excelnoob298Mar 10, 2020Copper Contributor
JKPieterse i see thanks. Im new to vba and need some help with vba coding. what do i have to rewrite to mac code from the windows code? and after writing this code my workbook close but not the whole excel which it did before. what can i insert in #endif for it to close the whole excel program?
- JKPieterseMar 11, 2020Silver Contributor
Without your code this is impossible to answer I'm afraid. The command to shut down Excel is the same in Windows and Mac: Application.Quit
- excelnoob298Mar 11, 2020Copper Contributor
JKPieterse the code i use for windows pc is written above, if you look at the first message i wrote. i tried to change it a little bit to mac but with no luck. i was asking if the code above can be used on mac or not? and what do i have to change for it to work on macbook? all the code is written in my first message.
thanks