VBA code :::::: Compile error: Expected : list separator or )

Prat14

New Member
Joined
Sep 18, 2014
Messages
5
I am trying to get the multiple results form a Range and cannot use vlookup so using INDEX Function.

My formula "=INDEX(Sheet1!$A:$I,SMALL(IF(Sheet1!$A:$A=$A$2,ROW(Sheet1!$A:$A)),ROW(2:2)),7)"
worked perfectly but not working in VBA code. I am getting "Compile error: Expected : list separator or )" and when i debug cursor goes to the last part of the code where i have ROW(2:2).

Please assist. In code i am trying to insert the value which i will get from index function into Sheet2-D6 cell.

Here is my code.
Sheets("Sheet2").Range("D6").Value = Application.WorksheetFunction.INDEX(Sheets("Sheet1").Range("$A:$I"),Application.WorksheetFunction.SMALL(Application.WorksheetFunction.IF(Sheets("Sheet1").Range("$A:$A")= Sheets("Sheet2").Range("A2").Value, Application.WorksheetFunction.ROW(Sheets("Sheet1").Range("$A:$A"))),Application.WorksheetFunction.ROW(2:2)),7)
 

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 about doing:

Code:
Sheets("Sheet2").Range("D6").Formula = _
    "=INDEX(Sheet1!$A:$I,SMALL(IF(Sheet1!$A:$A=$A$2,ROW(Sheet1!$A:$A)),ROW(2:2)),7)"
 
Upvote 0
Thank you for response VBA geek.

this is working 90% but i need to make it an array function how can i do it.

i tried Sheets("Sheet2").Range("D6").Formula = _ "{=INDEX(Sheet1!$A:$I,SMALL(IF(Sheet1!$A:$A=$A$2,ROW(Sheet1!$A:$A)),ROW(2:2)),7)}"
but it is not working

Please advise!
 
Upvote 0
Hello VBA Geek a quick question how can i make the row (2:2) Dynamic

I am using this:

For i = 1 To j


Sheets("Sheet2").Range("D" & k).FormulaArray = _
"=INDEX(Sheet1!$A:$I,SMALL(IF(Sheet1!$A:$A=$A$2,ROW(Sheet1!$A:$A)),ROW(i:i)),7)"

Next i
 
Upvote 0
since the ROW(i:i) in your formula below would just return every number from 1 to j as the loop runs, you can just replace it with i

Code:
For i = 1 To j


     Sheets("Sheet2").Range("D" & k).FormulaArray = _
            "=INDEX(Sheet1!$A:$I,SMALL(IF(Sheet1!$A:$A=$A$2,ROW(Sheet1!$A:$A))," & i & "),7)"


Next i



Hello VBA Geek a quick question how can i make the row (2:2) Dynamic

I am using this:

For i = 1 To j


Sheets("Sheet2").Range("D" & k).FormulaArray = _
"=INDEX(Sheet1!$A:$I,SMALL(IF(Sheet1!$A:$A=$A$2,ROW(Sheet1!$A:$A)),ROW(i:i)),7)"

Next i
 
Upvote 0

Forum statistics

Threads
1,214,626
Messages
6,120,602
Members
448,974
Latest member
ChristineC

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