How to take the average of all columns in Excel that contain a certain header string?

  • Thread starter Thread starter sesheldon
  • Start date Start date
S

sesheldon

Guest
Hi all. New VB programmer here.

I have written a program that records times, in seconds, into an excel spreadsheet. At the top of each column of data is a header, that contains the build and run number of the software being tested. For example, a column of data might be:

219.00.00.091 x64 Run 1

8.369333333
0.285
1.272666667
0.971666667
1.341666667
1.000666667
0.827333333
2.463

With the top cell being a header.

What I want to do is take the average of all the runs and insert a new row into the front of the data and delete the cells with the run data.

While I typically run the test 10 times, so there would typically be 10 columns of data, I would like to write it in a generic manner so that it simply finds all columns that contain the string "(build number) Run" and average their rows.

I believe I will be using something like this:



Dim GCell As RangeDim findheader as string = "219.00.00.091 x64 Run"

Set GCell = ActiveSheet.Cells.Find(findheader)


But I think this only gives the value of the first cell found?

I read about find here:

Range.Find Method (Excel)

Once I get my range of columns, then I can probably figure out how to take the average from there.

Thanks,

Continue reading...
 
Back
Top