![]() |
VBA Acting "Funny"
I have been trying to learn and write some VBA procedures in Excel on my
hope Excel version (XP). I wish to use these on my office version (2000). They are quite simple but the 2000 acts strange in several ways that it should not, based on what I keep reading in books and the help file. First, I do not have to declare each and every variable on the XP version. If they are not declared with a DIM statement then they are established as a variant on first use. This matches what I read in all the books and the help file in both versions. Second, I try to create a carriage return in a message box by using &Chr(13). It works fine on the XP version but the 200 version says," Compile Error: Cannot find project or library." What am I missing here? Is there a setting in the 2000 versions that I should alter? |
VBA Acting "Funny"
In article ,
"Shawn Shuler" wrote: First, I do not have to declare each and every variable on the XP version. If they are not declared with a DIM statement then they are established as a variant on first use. This matches what I read in all the books and the help file in both versions. You don't have to declare variables with Dim unless your modules have Option Explicit at the top. However, *especially* if you're just learning VBA, it's an *excellent* idea to put that Option Explicit in. You can do that automatically by, in the VBE, choosing Tools/Options/Editor and checking the Require variable declaration checkbox (which is probably the setting in your 2000 version). Having Option Explicit causes the compiler to catch all kinds of errors - from spelling to type mismatches, and makes the debugging process much easier Second, I try to create a carriage return in a message box by using &Chr(13). It works fine on the XP version but the 200 version says," Compile Error: Cannot find project or library." What am I missing here? Is there a setting in the 2000 versions that I should alter? I'm not sure why that would cause an error. You could try using a space between the & and the Chr(13) instead. However, I'd recommend, at least to start, that you learn the enumerated value vbNewLine instead, only because it works cross-platform (WinXL and MacXL), where Chr(13) doesn't. |
VBA Acting "Funny"
I will try both of your suggestions. I appreciate the help.
"JE McGimpsey" wrote in message ... In article , "Shawn Shuler" wrote: First, I do not have to declare each and every variable on the XP version. If they are not declared with a DIM statement then they are established as a variant on first use. This matches what I read in all the books and the help file in both versions. You don't have to declare variables with Dim unless your modules have Option Explicit at the top. However, *especially* if you're just learning VBA, it's an *excellent* idea to put that Option Explicit in. You can do that automatically by, in the VBE, choosing Tools/Options/Editor and checking the Require variable declaration checkbox (which is probably the setting in your 2000 version). Having Option Explicit causes the compiler to catch all kinds of errors - from spelling to type mismatches, and makes the debugging process much easier Second, I try to create a carriage return in a message box by using &Chr(13). It works fine on the XP version but the 200 version says," Compile Error: Cannot find project or library." What am I missing here? Is there a setting in the 2000 versions that I should alter? I'm not sure why that would cause an error. You could try using a space between the & and the Chr(13) instead. However, I'd recommend, at least to start, that you learn the enumerated value vbNewLine instead, only because it works cross-platform (WinXL and MacXL), where Chr(13) doesn't. |
All times are GMT +1. The time now is 02:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com