Iterating through an Array

takhtar

New Member
Joined
Sep 17, 2012
Messages
2
Hi,

I have the following code:

Function Extract(Products As String) As String
Dim softProdArray() As String
Dim out As String
Dim prod As Variant
softProdArray = Split(Products, Chr(10))
For Each prod In softProdArray
If InStr(prod, "ORACLE") > 0 Or InStr(prod, "SYBASE") > 0 Or InStr(prod, "MS SQL") > 0 _
Or InStr(prod, "SYBASE IQ") > 0 Or InStr(prod, "ISQL") > 0 Or InStr(prod, "VERITAS") > 0 Then
out = out & prod & Chr(10)
End If
Next prod
Extract = out
End Function


I am basically pulling in a cell with items separated by carriage returns. I want to take the cell split it into an array delimited by carriage returns then evaluate each element, then output any findins in another variable, appending until I finish looping through the array. That final output I pass back to another cell when I call this funtion from. In that cell I call the function with the following syntax: Extract(A1), where A1 is my data that I am evaluating. I think my major problem is the for loop. The error i am gettting is "That function is not valid," not very descriptive.

Thanks in advance
Tan
 
Welcome to MrExcel.

Try renaming your function. The name Extract is reserved for the Copy to range in Advanced Filter.
 
Last edited:
Upvote 0

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