vba does not work in excel 2016

cds

Board Regular
Joined
Mar 25, 2012
Messages
84
I have the following vba which works perfecctly ok excel 2007 but when use it excel 2016 pc , excel sheet works very very slowly and macros does get updated . Please help me out

Code:
Function Lookup_concatn(Search_stringA As String, Search_in_colA As Range, _
Search_stringB As String, Search_in_colB As Range, Return_val_col As Range)


Dim i As Long
Dim result As String


For i = 1 To Search_in_colA.Count
If Search_in_colA.Cells(i, 1) = Search_stringA And _
Search_in_colB.Cells(i, 1) = Search_stringB Then
result = result & " " & Return_val_col.Cells(i, 1).Value
End If
Next i


Lookup_concatn = (result)


End Function

thanks
 
Last edited by a moderator:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
try..
Code:
Function Lookup_concatn(Search_stringA As String, Search_in_colA As Range, _
                    Search_stringB As String, Search_in_colB As Range, Return_val_col As Range)

Dim a() As Variant, b() As Variant, c() As Variant
Dim i As Long, result As String

a = Search_in_colA.Value
b = Search_in_colB.Value
c = Return_val_col.Value

For i = 1 To UBound(a)
    If a(i, 1) = Search_stringA And b(i, 1) = Search_stringB Then result = result & " " & c(i, 1)
Next

Lookup_concatn = (result)

End Function
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,792
Members
449,048
Latest member
greyangel23

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