variables

alarants

Registered User.
Local time
Today, 14:00
Joined
Apr 17, 2009
Messages
46
Hi,

I am trying to execute th code:
ApXL.Activesheet.Range("E371").Formula = "=sum(a5:a300)"
It works fine but when I am trying to change it to
ApXL.Activesheet.Range("E371").Formula = "=sum(a5:aP)"
where P is a variable it is not working any more. I have tried all methods I imagine but nothing. Does anybody have experience like that. Later on I need to change a and E371 to variabel as well.
Regards
 
you might have success with something like

ApXL.Activesheet.Range("E371").Formula = "=sum(a5:a" & p & ")"

but not 100% sure whether you can concatenate like that in excel formulae
 
Sorry, but "Expected end of statement" on last quotation mark is answer from my laptop.
 
It actually works when I do
ApXL.Activesheet.Range("E371").Formula = "=sum(a5:a" & P
but I don't know why. How it works without last parenthesis remains mystery to me.
 
you might have success with something like

ApXL.Activesheet.Range("E371").Formula = "=sum(a5:a" & p & ")"

but not 100% sure whether you can concatenate like that in excel formulae

Yes you can 100% sure, and IMHO this should work... strange that the OP gets an error?
 

Users who are viewing this thread

Back
Top Bottom