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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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?
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,240
Members
448,555
Latest member
RobertJones1986

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
Back
Top