Adding alternate columns only if they visible

excelnoob1985

New Member
Joined
Jul 22, 2015
Messages
6
Hi,

I have data in a sheet which runs from column 'F' to column 'GU' over hundreds of rows. Every column (with headers on row 7) is alternatively named "Hours" and "Fees". Is there a way to have a total figure in columns 'GW' (for Hours) and 'GX' (for Fees) which adds up the respective Hours and Fees figure for each row, and only for visible columns (as the columns from 'F' to 'GU' are needed to be hidden / unhidden repetitively by users as part of using the workbook).

I have used the following code:

Public Function SumVisible(r As Range) As Double
Dim rC As Range
Dim d As Double

Application.Volatile
On Error Resume Next
For Each rC In r
If Not (rC.EntireRow.Hidden Or rC.EntireColumn.Hidden) Then _
If VarType(rC.Value) = vbDouble Then _
d = d + rC.Value

SumVisible = d
Next rC
End Function

Which adds the values in each row for every column but I can't get it work for every alternate row so i have totals for "Hours" and "Fees" separately.

Is there a way to add by reference to the title of the column in row 7, and for the formula to add data in only visible columns?

Thanks!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,214,832
Messages
6,121,849
Members
449,051
Latest member
excelquestion515

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