Solved

WriteExcel AVERAGE containing variable as end Range

Posted on 2004-09-14
1
177 Views
Last Modified: 2013-12-25
I have a perl program that uses Spreadsheet::WriteExcel.   I am using the AVERAGE and SUM functionality in the following manner:
      $worksheet->write('D'.$nplay, '=AVERAGE(D2:D26)',$average);
      $worksheet->write('E'.$nplay, '=AVERAGE(E2:D26)',$onezero);
      $worksheet->write('K'.$nplay, '=SUM(K2:K26)',$currency);
      $worksheet->write('O'.$nplay, '=SUM(O2:O26)',$currency);

This works fine most of the time but the problem is that the end of the range can change on occasion.  I need to be able to replace the "26" in each of the above examples with a variable.  I have tried the following and it does not seem to be correct syntax:
my $avg1="D".$avg;       
$worksheet->write('D'.$nplay, '=AVERAGE(D2:"$avg1")',$average);

any help here would be greatly appreciated.  
0
Comment
Question by:spoma
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
Comment Utility
$worksheet->write('D'.$nplay, "=AVERAGE(D2:$avg1)",$average);
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now