Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel 5.0 compatability problem?
Bill,
I guess that it is telling you that Default is a reserved word that you cannot now use as a variable name. The other looks like testing a string for False won't work. Try changing the declaration of LotReq to variant. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Bill C" wrote in message ... I wrote a macro using Excel 5.0 and it has been running great for several years using 5.0 but client has upgraded to newer version of Excel and problems exist. Dim LotReq As String Message = "Choose ""OK"" For All Lots, Or " & Chr(13) & "Enter Lot Number Requested." Title = " CHOOSE LOT" Default = "ALL" LotReq = InputBox(Message, Title, Default) If LotReq = "" Or LotReq = False Then EndAll The following statements are not working: Default = "ALL" ( get error about const assignment ) If LotReq = "" Or LotReq = False Then EndAll ( stops program ) Also Excel appears to be returning "false" on this statement when Pmts = 0.00 If Pmts = False Then EndAll I do not have access to current Excel program. Can anyone spot the problem? TIA, Bill C. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel 5.0 compatability problem?
Current versions of VBA support "named arguments" (equivalent to built-in variable names).
In the case of InputBox, the names of the 1st 3 arguments are Prompt, Title, and Default. Excel is probably getting confused by your use of Title and Default as variable names. Try changing them, perhaps by adding an underscore at the end: Title_ and Default_ Names arguments allow you to supply the arguments in any order if you use the syntax like this: LotReq = Inputbox(Title:=Title_, Default:=Default_, Prompt:=Message) As for the problem with the comparison, first let me say that it works for me in Excel XP. If I write Dim x As String x = "0.00" Debug.Print x = False It prints True. But if this isn't working for you then I would convert the string to a number using the CDbl function, then compare with the numeric value 0: If LotReq = "" Or CDbl(LotReq) = 0 Then EndAll I assume EndAll is the name of another sub? PS: It's a good idea to Dim all of your variables. There are no Dim statements for Message, Title, and Default. On Sun, 6 Jun 2004 13:51:01 -0700, "Bill C" wrote: I wrote a macro using Excel 5.0 and it has been running great for several years using 5.0 but client has upgraded to newer version of Excel and problems exist. Dim LotReq As String Message = "Choose ""OK"" For All Lots, Or " & Chr(13) & "Enter Lot Number Requested." Title = " CHOOSE LOT" Default = "ALL" LotReq = InputBox(Message, Title, Default) If LotReq = "" Or LotReq = False Then EndAll The following statements are not working: Default = "ALL" ( get error about const assignment ) If LotReq = "" Or LotReq = False Then EndAll ( stops program ) Also Excel appears to be returning "false" on this statement when Pmts = 0.00 If Pmts = False Then EndAll I do not have access to current Excel program. Can anyone spot the problem? TIA, Bill C. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel 5.0 compatability problem?
I wrote a macro using Excel 5.0 and it has been running great for several
years using 5.0 but client has upgraded to newer version of Excel and problems exist. Dim LotReq As String Message = "Choose ""OK"" For All Lots, Or " & Chr(13) & "Enter Lot Number Requested." Title = " CHOOSE LOT" Default = "ALL" LotReq = InputBox(Message, Title, Default) If LotReq = "" Or LotReq = False Then EndAll The following statements are not working: Default = "ALL" ( get error about const assignment ) If LotReq = "" Or LotReq = False Then EndAll ( stops program ) Also Excel appears to be returning "false" on this statement when Pmts = 0.00 If Pmts = False Then EndAll I do not have access to current Excel program. Can anyone spot the problem? TIA, Bill C. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel compatability | Excel Discussion (Misc queries) | |||
Excel Compatability mode?????? | Excel Discussion (Misc queries) | |||
Excel 2007 Compatability | Excel Discussion (Misc queries) | |||
Excel VBA Backwards Compatability Problem - 2002-97 | Excel Programming | |||
Excel 2002 and 97 compatability | Excel Programming |