Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have the following function in my code. h = "06180J435448" intClmCterTotal = CLng(Evaluate("=SUMPRODUCT(--(" & _ Range("Sum_Report_Name").Address(True, True, xlA1, True) & _ "=""HITNOIJ ""), --(" & Range("Sum_Claim_Number").Address(True, True, xlA1, True) & _ "=" & h & "))")) The value returned is 2015 which I believe is an error code (Application-defined or object-defined error). When I change the variable h to a hard coded claim number, the code returns 12 which is the correct answer. intClmCterTotal = CLng(Evaluate("=SUMPRODUCT(--(" & _ Range("Sum_Report_Name").Address(True, True, xlA1, True) & _ "=""HITNOIJ ""), --(" & Range("Sum_Claim_Number").Address(True, True, xlA1, True) & _ "=""06180J435448""))")) I need to have the claim number as a variable so I can look up different claims and apply the rest of the code to them. What am I doing wrong? Any help would be appreciated. -- JAVB ------------------------------------------------------------------------ JAVB's Profile: http://www.excelforum.com/member.php...o&userid=29304 View this thread: http://www.excelforum.com/showthread...hreadid=559019 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try it like this:
h = "06180J435448" intClmCterTotal = CLng(Evaluate("=SUMPRODUCT(--(" & _ Range("Sum_Report_Name").Address(True, True, xlA1, True) & _ "=""HITNOIJ ""), --(" & Range("Sum_Claim_Number").Address(True, True, xlA1, True) & _ "=""" & h & """))")) -- Regards, Tom Ogilvy "JAVB" wrote: I have the following function in my code. h = "06180J435448" intClmCterTotal = CLng(Evaluate("=SUMPRODUCT(--(" & _ Range("Sum_Report_Name").Address(True, True, xlA1, True) & _ "=""HITNOIJ ""), --(" & Range("Sum_Claim_Number").Address(True, True, xlA1, True) & _ "=" & h & "))")) The value returned is 2015 which I believe is an error code (Application-defined or object-defined error). When I change the variable h to a hard coded claim number, the code returns 12 which is the correct answer. intClmCterTotal = CLng(Evaluate("=SUMPRODUCT(--(" & _ Range("Sum_Report_Name").Address(True, True, xlA1, True) & _ "=""HITNOIJ ""), --(" & Range("Sum_Claim_Number").Address(True, True, xlA1, True) & _ "=""06180J435448""))")) I need to have the claim number as a variable so I can look up different claims and apply the rest of the code to them. What am I doing wrong? Any help would be appreciated. -- JAVB ------------------------------------------------------------------------ JAVB's Profile: http://www.excelforum.com/member.php...o&userid=29304 View this thread: http://www.excelforum.com/showthread...hreadid=559019 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
So h is a string?
How about: "=""" & h & """))")) or "=" & chr(34) & h & chr(34) & "))")) to wrap it with quotation marks. JAVB wrote: I have the following function in my code. h = "06180J435448" intClmCterTotal = CLng(Evaluate("=SUMPRODUCT(--(" & _ Range("Sum_Report_Name").Address(True, True, xlA1, True) & _ "=""HITNOIJ ""), --(" & Range("Sum_Claim_Number").Address(True, True, xlA1, True) & _ "=" & h & "))")) The value returned is 2015 which I believe is an error code (Application-defined or object-defined error). When I change the variable h to a hard coded claim number, the code returns 12 which is the correct answer. intClmCterTotal = CLng(Evaluate("=SUMPRODUCT(--(" & _ Range("Sum_Report_Name").Address(True, True, xlA1, True) & _ "=""HITNOIJ ""), --(" & Range("Sum_Claim_Number").Address(True, True, xlA1, True) & _ "=""06180J435448""))")) I need to have the claim number as a variable so I can look up different claims and apply the rest of the code to them. What am I doing wrong? Any help would be appreciated. -- JAVB ------------------------------------------------------------------------ JAVB's Profile: http://www.excelforum.com/member.php...o&userid=29304 View this thread: http://www.excelforum.com/showthread...hreadid=559019 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Variable Problem. | Excel Programming | |||
Having a problem using a variable to add a 'name' | Excel Programming | |||
Variable problem | Excel Programming | |||
vba variable problem | Excel Programming | |||
Problem trying to us a range variable as an array variable | Excel Programming |