Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

= sum error 1

Status
Not open for further replies.

tyone

MIS
Feb 27, 2004
22
US
#NAME?

the code behind this:
ActiveSheet.Cells(lngRow, 7).Formula = "=sum(rng:rng1)"

rng and rng1 shows the cells that they should be like $G$2 and $G$5.

Thanks in advance
 
Provided rng and rng1 are strings:
ActiveSheet.Cells(lngRow, 7).Formula = "=SUM(" & rng & ":" & rng1 & ")"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
thanks PHV was just what i was looking for....
 
why does it need the & symbol in there. just curious. also is there a way to bold those cells also.

thanks so much in advance
 
& is the string concatenation operator.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Range.Font.Bold = true

the way you had it written, the formula entered into the cell would be

=SUM(rng:rng1)

which excel cannot recognise

Becuase you are holding rng & rng1 as variables, you must insert them into the formula string as seperate entities (as PHV has shown you)

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top