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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XL WKbook Totals Col w/the Same Name 1

Status
Not open for further replies.

ZoomDah

Programmer
Mar 8, 2004
30
0
0
US
I am trying to total columns in code in Excel.
It worked untill I realized that Column8 on First Worksheet and Column8 on Second Sheet are totaling as well.

I need to figure out way to Name those Columns uniquely so WKbook does not total all Columns with the same name in Workbook.

I am counting lenght of the column in code as well so I know where to place Total row.

For s = 6 To 21
Set SumCol = Selection.QueryTable.ResultRange.Columns(s)
ExcelWK.Names.Add Name:=CStr("C" & xSheet & s), RefersTo:="=xSheet!column(s)" THIS PART HAS SYNTAX PROBLEM I THINK
SumRange = "C" & xSheet & s
' SumCol.Name = CStr(SumRange)
' SumRange = "C" & xSheet & s
' SumCol.Name = "Column" & s
SumCol.End(xlDown).Offset(2, 0).Font.Bold = True
SumCol.End(xlDown).Offset(2, 0).Formula = "=sum(SumRange)"
Next s
 
Try something like this:
RefersTo:="=" & xSheet & "!" & Column(s).Address

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top