Hi all,
Have trawled around for ages and not found quite what I need, so was hoping that someone here could help me.
I have created a function to count comments in a sheet called "data", which works fine if I specify the sheet to "count in" within the function code...and then only send a range in the passing parameter.
What I really want is to be able to create a cell in a SUMMARY sheet...which says something like =CountComments(data!c1:c10) so it passes both the working sheet I want the counting to be in...as well as the range within it.
If I send the above into a RANGE datatype I get a silent error...function simply doesnt work, if I put back to =CountComments(c1:c10) and specify the data sheet specifically...its works fine again.
Code:
Function CountComments(rCommentRange As Range, rCode As String, rColumn As Integer) As Long
* rCommentRange is the range and ideally worksheet to check for comments in cells
* rCode is a code to check if the comment is allocated to a group I pass in
* rColumn is just to tell me which column the group code is held in for check above
The functionality of the code is fine, its just the Range that's the issue, but have included to show what I am using.
full function call would be =CountComments(data!C1:C10,"BBC",2)
I guess questions are:
1) Is Range the correct datatype if sending both sheet AND range into the function ?
2) If it is am I missing a means by which to select that sheet attribute out (not getting that far so don't think is right)
3) Requirement is a means of sending both sheet and range into a function and then using this as the driving sheet to access for the functions purpose.
This must be possible as the built in =sum function does this perfectly.
Would be very grateful if someone could help me !
Ed.
Have trawled around for ages and not found quite what I need, so was hoping that someone here could help me.
I have created a function to count comments in a sheet called "data", which works fine if I specify the sheet to "count in" within the function code...and then only send a range in the passing parameter.
What I really want is to be able to create a cell in a SUMMARY sheet...which says something like =CountComments(data!c1:c10) so it passes both the working sheet I want the counting to be in...as well as the range within it.
If I send the above into a RANGE datatype I get a silent error...function simply doesnt work, if I put back to =CountComments(c1:c10) and specify the data sheet specifically...its works fine again.
Code:
Function CountComments(rCommentRange As Range, rCode As String, rColumn As Integer) As Long
* rCommentRange is the range and ideally worksheet to check for comments in cells
* rCode is a code to check if the comment is allocated to a group I pass in
* rColumn is just to tell me which column the group code is held in for check above
The functionality of the code is fine, its just the Range that's the issue, but have included to show what I am using.
full function call would be =CountComments(data!C1:C10,"BBC",2)
I guess questions are:
1) Is Range the correct datatype if sending both sheet AND range into the function ?
2) If it is am I missing a means by which to select that sheet attribute out (not getting that far so don't think is right)
3) Requirement is a means of sending both sheet and range into a function and then using this as the driving sheet to access for the functions purpose.
This must be possible as the built in =sum function does this perfectly.
Would be very grateful if someone could help me !
Ed.
Last edited: