Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
What does # mean in front of IF statements
I have a couple macros that run on PC and Macs. I learned that I have
to put a "#" in front of the file access code to make the macro utilize the appropriate OS commands: Example: #If Win32 Then LoadFileName = Application.GetOpenFilename(FileFilter) #ElseIf Mac Then LoadFileName = Application.GetOpenFilename() #End If Can someone explain why the # is necessary and what it means? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
What does # mean in front of IF statements
That means conditional statements.
In VBA, when the code is compiled, the #If statement is checked , and if true (a windows system in the example) it compiles one command, if not, it compiles the other. It is a very useful method to allow your code to be platform, or version, independent. -- HTH Bob Phillips (replace xxxx in the email address with gmail if mailing direct) wrote in message ups.com... I have a couple macros that run on PC and Macs. I learned that I have to put a "#" in front of the file access code to make the macro utilize the appropriate OS commands: Example: #If Win32 Then LoadFileName = Application.GetOpenFilename(FileFilter) #ElseIf Mac Then LoadFileName = Application.GetOpenFilename() #End If Can someone explain why the # is necessary and what it means? Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
What does # mean in front of IF statements
I didn't realize that VBA compiles on-the-fly before it runs. In VB,
you have to specifically compile the code. Thanks for the explanation. That is handy for cross-platform application. So are the "win32" and "mac" just system variables that each OS sets in the VBA code? And now a new problem... my conditional statements are just being ignored. They were working fine, but now when it gets to the #IF, it just skips to the next section of code and doesn't even check the condition. It appears to only be a problem on the one computer I program on. Any ideas what happened? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I keep a zero (0) at the front of a set of numbers. | Excel Worksheet Functions | |||
IF Statements (Mutliple Statements) | Excel Worksheet Functions | |||
front end zero | Excel Discussion (Misc queries) | |||
zero in front of a number | Excel Discussion (Misc queries) | |||
operator statements, shorting when reusing one of the statements? | Excel Programming |