|
-
Apr 11th, 2008, 02:33 PM
#1
Thread Starter
Addicted Member
[RESOLVED] IF Clause - syntx error
what is the syntax error below
If Ucase(aSheet.Cells(4."e")).value = "ABCD" AND if aSheet.Cells(i,"d") <> "" And dic.Exists((aSheet.Cells(i,"d")) then
MsgBox ("ABCD ORG NOT CONSISTENT" )
Exit Sub
End if
-
Apr 11th, 2008, 03:07 PM
#2
Addicted Member
Re: IF Clause - syntx error
a couple of things I see. There is a . instead of a , between the 4 and "e" in the first cell reference.
Also you should reference the columns by number and not character so you'd use
Code:
If Ucase(aSheet.Cells(4, 5)).value = "ABCD" AND if aSheet.Cells(i,4) <> "" And dic.Exists((aSheet.Cells(i,4)) then
MsgBox ("ABCD ORG NOT CONSISTENT" )
Exit Sub
If you're going to be crazy, you have to get paid for it or else you're going to be locked up. -- Hunter Thompson
-
Apr 11th, 2008, 03:15 PM
#3
Thread Starter
Addicted Member
Re: IF Clause - syntx error
Still it shows syntax error
-
Apr 11th, 2008, 04:20 PM
#4
Re: IF Clause - syntx error
If Ucase(aSheet.Cells(4."e")).value = "ABCD" AND aSheet.Cells(i,"d") <> "" And dic.Exists((aSheet.Cells(i,"d")) then
don't need 2 ifs
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 11th, 2008, 06:32 PM
#5
Thread Starter
Addicted Member
Re: IF Clause - syntx error
westconn
actaully i want
for example if the d cell has
par
par
car
i need only take par and par only if it is anythign other than par
it comes mSG BOX NOT CONSTRAINT
what i did the above is that one is right? please let me know
thanks
-
Apr 11th, 2008, 11:11 PM
#6
Re: IF Clause - syntx error
i don't believe you need to check if cells(i,"d") is both <> "" and dic.exists, if it was "" then it can not dic.exists, whatever dic.exists is
if you are not sure why it is returning false you need to evaluate both parts separately to fond out what the problem is
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 13th, 2008, 11:48 PM
#7
Lively Member
Re: IF Clause - syntx error
 Originally Posted by india123
what is the syntax error below
If Ucase(aSheet.Cells(4."e")).value = "ABCD" AND if aSheet.Cells(i,"d") <> "" And dic.Exists((aSheet.Cells(i,"d")) then
MsgBox ("ABCD ORG NOT CONSISTENT" )
Exit Sub
End if
Hi there...
I believe apart from the .cells(R,C).value number issue the problem with the syntax is that you did not nest the second if statement.
If Ucase(aSheet.Cells(4."e")).value = "ABCD" then
if aSheet.Cells(i,"d") <> "" And dic.Exists((aSheet.Cells(i,"d")) then
MsgBox ("ABCD ORG NOT CONSISTENT" )
Exit Sub
end if
End if
cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|