# Finding issue in If elseif else with For each Loop

#### Arunachaljois

##### Board Regular
Finding issue in If elseif else with For each Loop
I have tried this below code but i'm getting in Y column filled with W005. Colud you please help me on this ? i have uploaded a images also.
For Each cell In Range("I2:I" & LR)
If cell.Value = "W100" Then
Range("Y2:Y" & LR).Formula = "=CONCATENATE(RC[-23],""000"",RC[-20],""W004"")"
ElseIf cell.Value = "W102" Then
Range("Y2:Y" & LR).Formula = "=CONCATENATE(RC[-23],""000"",RC[-20],""W005"")"
Else
Range("Y2:Y" & LR).Formula = "=CONCATENATE(RC[-23],""000"",RC[-20],RC[-16])"
End If
Next cell

#### Attachments

• 2020-08-01_195537.png
40.8 KB · Views: 8

#### Fluff

##### MrExcel MVP, Moderator
You will need to do what I said in post#49

### Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},\$Z\$1:\$Z\$99,\$Y\$1:\$Y\$99),2,False) to lookup Y values to left of Z values.

#### Arunachaljois

##### Board Regular
You mean either use sheets or worksheets ? any of one ?

#### Fluff

##### MrExcel MVP, Moderator
No.
Look at your code & the two examples I showed, of how to ensure that the code is running on the correct sheet.

#### Arunachaljois

##### Board Regular
Yes i have done it to Sheets
But still is not working

#### Fluff

##### MrExcel MVP, Moderator

I edited post#53 as I misunderstood what you were saying.

#### Arunachaljois

##### Board Regular
Yes i got it
But button not working properly in RED border code
Yellow highlighted one is working fine with same button

#### Attachments

• 2020-08-02_202055.png
12.8 KB · Views: 2

#### Fluff

##### MrExcel MVP, Moderator
You have not done either of what I suggested.
Sorry but I cannot afford to spend any more time this.

#### Arunachaljois

##### Board Regular
Kindly request could you please just clearly explain one more last time

Replies
10
Views
110
Replies
3
Views
52
Replies
2
Views
83
Replies
6
Views
47
Replies
1
Views
48