NukedWhale
01-23-2009, 01:24 PM
I need to sum all the rows, not including the header row, in a column specified by the user for a specific worksheet.
The number of rows is MyRows
The user specified column is WeightingRange. WeightingRange is a string and the user entered in the column letter as text. I.e WeightingRange=G.
The worksheet is SourceSheet
I found a website that recommended using excel's built in functions.
This is an example they gave:
MySum = Application.WorksheetFunction.Sum(Range("A1:A100"))
How would I adapt this for what I want to do? This is how far I am. But I don't know how to make it refer to a specific worksheet, or if it would even work.
MySum = Application.WorksheetFunction.Sum(Range("&Weightingrange & "2:" & WeightingRange & str(MyRows)&"))
The number of rows is MyRows
The user specified column is WeightingRange. WeightingRange is a string and the user entered in the column letter as text. I.e WeightingRange=G.
The worksheet is SourceSheet
I found a website that recommended using excel's built in functions.
This is an example they gave:
MySum = Application.WorksheetFunction.Sum(Range("A1:A100"))
How would I adapt this for what I want to do? This is how far I am. But I don't know how to make it refer to a specific worksheet, or if it would even work.
MySum = Application.WorksheetFunction.Sum(Range("&Weightingrange & "2:" & WeightingRange & str(MyRows)&"))