IF, LEN and VLOOKUP combined

Mike Stewart

New Member
Joined
Mar 19, 2019
Messages
2
Hello.

I'm struggling with a formula using IF, LEN and VLOOKUP. I need to manipulate what VLOOKUP returns. If it returns a 10 character string I need to only pull through the first 5 characters, otherwise return the entire string.



=IF(LEN(VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0)=10),LEFT(VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0),5),VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0))



Column A in my "Working" spreadsheet contains unique values. I'm putting the formula into cell B2 (and replicating down entire column) and referencing another spreadsheet (Powys Users.xlsx). Column A in the referenced spreadsheet contains unique values (and will somewhere have a match to my Working spreadsheet's A column entries) and its column 3 contains a text string. If this text string is 10 characters long I want to pull through just the first 5 characters, otherwise pull through the entire string.


At the moment it's just returning 5 characters no matter what is found.



I've cut it down for testing to: =IF(LEN(VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0)=10),"Yes", "No")



This is returning "Yes" no matter what it finds in the referenced spreadsheet. I know some matches are 10 chars and others 5 or 6.


Any help will be much appreciated.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hello,

Could this help :

Code:
=LEFT(VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0),5)
 
Upvote 0
you got the bracket in the wrong place

Code:
=IF(LEN(VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0)[COLOR="#FF0000"])=10[/COLOR],LEFT(VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0),5),VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0))
 
Upvote 0
Fantastic Alan, thank you very much.

you got the bracket in the wrong place

Code:
=IF(LEN(VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0)[COLOR=#ff0000])=10[/COLOR],LEFT(VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0),5),VLOOKUP(A2,'[Powys Users.xlsx]DataSheet'!$A$1:$C$10000,3,0))
 
Upvote 0
hey guys, i was wondering if this combination of formulas can help me with my sheets
i also need to manipulate vlookup return value. if from the sheet A it returns "Male", then on the sheet B i need the return to be "M", if not then just blank.

i tried using this formula but it's not working
Excel Formula:
=IF(LEN(VLOOKUP(A1,'Form responses 1'!C3:F,32,0))=Male,"L",VLOOKUP(VLOOKUP(A1,'Form responses 1'!C3:F,32,0))

any help would be appreciated, thankyouu
 
Upvote 0
You would do better starting a new thread for this question, explaining what you are trying to do, including what the ranges you are looking at are, as you current formula is invalid.
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,530
Members
448,969
Latest member
mirek8991

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