Forum Discussion
Can you guys review this code?
- excelnoob298Mar 09, 2020Copper Contributor
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
- JKPieterseMar 10, 2020Silver ContributorThe # signs are compiler directives. VBA Only compiles and runs the relevant portion(s).
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?