Excel Function in VBA hidden rows

ajamr

New Member
Joined
Nov 19, 2017
Messages
3
Hi everyone,

I created a function in excel vba, saved it in the personal.xlsb, and it works exactly as I want it, the only problem is that it only works when I "unhide" the header row. I tried searching the problem but I couldn't find anything.

Example Table

Header 1Header 2Header 3
Subitem 1160
Subitem 2432
Subitem 3150
Subitem 4003

<tbody>
</tbody>


The function code below...

Code:
Public Function BOQTakeOff(subitem As Range, header As Range)

Dim txt As String
For Each cell In subitem
If cell.Value > 0 Then
txt = txt & " " & cell.Value & " x " & Cells(header.Row, cell.Column).Value & "," & vbCrLf
End If
Next cell
BOQTakeOff = txt

End Function

The end result will be something like

1 x Header 1,
6 x Header 2,
4 x Header 1,
3 x Header 2,
2 x Header 3,
1 x Header 1,
5 x Header 2,
3 x Header 3,

<tbody>
</tbody>

The code works, perfectly, but only when I have to unhide the "header" row in my original table...

Really appreciate your help...
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
How are you using this function? From a macro, or from a sheet?
Using it in a sheet works for me

Excel 2013 32 bit
DEFGH
5
7Subitem 11601 x Header 1, 6 x Header 2,
8Subitem 2432
9Subitem 3150
10Subitem 4003
Test1
Cell Formulas
RangeFormula
H7=BOQTakeOff(E7:G7,E6:G6)
 
Upvote 0
I am reading this from a macro of the personal.xlsb file.
If I use it in the same workbook, it works without a flaw, however; when reading it as a macro from the personal.xlsb file, i have to un-hide the source table rows in order to make it work.
 
Upvote 0
a) What macro calls the function?
b) How is the header set in that macro?
 
Upvote 0
Your code working,
but I have to lock the header address, so the result are exactly like yours.

=PERSONAL.XLSB!BOQTakeOff(E2:G2,$E$1:$G$1)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

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