Hidden Columns

bigfoot

Active Member
Joined
May 1, 2002
Messages
321
hi
i have columns G through P, with values on the rows and a total in the column. i have a total in column Q, which sums the totals in all the columns. at times the last 3 columns are hidden. how do i adjust the total in column Q to only sum the visible columns. thanks for the help.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

bigfoot

Active Member
Joined
May 1, 2002
Messages
321
thanks for the response. i tried it, as well as using 109, and it didnt work.
 

baitmaster

Well-known Member
Joined
Mar 12, 2009
Messages
2,042
it definitely works for autofiltered data sets, apparently not if you just hide sections though. You could use a UDF for this, but its not ideal

Can you reset the calculation whenever you hide/show the column instead? How does this feature work?
 

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
The Subtotal() builtin function seems to only work on ROWS -- Not Columns
A UDF is necessary (it seems) - Paste the below into a standard module and in your
worksheet column Q - first data row (say row 2) enter:

=SumVisColumns(G2:P2)

Code:
Function SumVisColumns(Rg As Range)
Dim x As Range
Dim tot As Double
  Application.Volatile
  tot = 0
  For Each x In Rg
     If Not x.Columns.Hidden Then
     tot = tot + x
     End If
  Next x
  SumVisColumns = tot
End Function
 

Forum statistics

Threads
1,141,841
Messages
5,708,911
Members
421,598
Latest member
NewHere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top