Log in

View Full Version : Q: VBA - using a range of strings as an argument



mwdking
11-11-2013, 05:53 PM
Dear all,

I am new to this forum and decided to pose you a question that drives me nuts.

I want to create a function that has 2 arguments:

A single cell that contains a string = Role
A range of cells containing strings = RangeR


I compare the content of Role to the content of each of the cells in RangeR.

As an example code I then return the value of the second comparison.

Could some check what I did wrong in my code?:


Function getresponsible(Role As String, RangeR As Range)

Dim MatchingArray(1 To 5) As Boolean
Dim dum As Boolean

For i = 1 To 5
dum = Application.WorksheetFunction.Search(Role, RangeR(1, i))
MatchingArray(i) = Application.WorksheetFunction.IsNumber(dum)
Next i

getresponsible = MatchingArray(2)

End Function

https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)

patel
11-11-2013, 10:45 PM
can you attach a sample file and explain better your goal ?