We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
The Forum now has a brand new text editor, adding a bunch of handy features to use when creating posts. Read more in our how-to guide

Removing Text from a Cell

Cotta
Cotta Posts: 3,667 Forumite
Hi All,


I have a code in a cell to return a value and the value returned is exactly what I require, however I was wondering if it is possible to remove the last four characters returned and if so how is this done? The code I am using is as follows:

=VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!H29,'Personal Finance'!1:1,0),0)

Comments

  • Cotta
    Cotta Posts: 3,667 Forumite
    Thanks,
    I have tried to use the solutions within this already, however the following returns errors:

    =right(H30,-4),VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!H29,'Personal Finance'!1:1,0),0)
  • Carrot007
    Carrot007 Posts: 4,534 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    edited 10 August 2016 at 11:22AM
    =right(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!H29,'Personal Finance'!1:1,0),0),len(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!H29,'Personal Finance'!1:1,0),0)-4)

    but did you not ask for =left in the first post?
  • bingo_bango
    bingo_bango Posts: 2,594 Forumite
    Cotta wrote: »
    Thanks,
    I have tried to use the solutions within this already, however the following returns errors:

    =right(H30,-4),VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!H29,'Personal Finance'!1:1,0),0)

    This is just a syntax error.
    This version is trying to remove the last 4 characters from the cell, and then doing the lookup. It can't remove characters if the cell is blank (which it will be until the lookup completes).
  • Cotta
    Cotta Posts: 3,667 Forumite
    Carrot007 wrote: »
    =right(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!H29,'Personal Finance'!1:1,0),0),len(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!H29,'Personal Finance'!1:1,0),0)-4)

    but did you not ask for =left in the first post?


    Yes it's the last four characters in the cell that I am trying to remove. Attempting your formula (copied below) and I am being returned the "#VALUE!" error message.


    =RIGHT(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!$H$29,'Personal Finance'!$1:$1,0),0),LEN(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!$H$29,'Personal Finance'!$1:$1,0),0)-4))
  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Cotta wrote: »
    Yes it's the last four characters in the cell that I am trying to remove. Attempting your formula (copied below) and I am being returned the "#VALUE!" error message.


    =RIGHT(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!$H$29,'Personal Finance'!$1:$1,0),0),LEN(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!$H$29,'Personal Finance'!$1:$1,0),0)-4))

    Looks like an issue with brackets. Try this:-
    =RIGHT(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!$H$29,'Personal Finance'!$1:$1,0),0),LEN(VLOOKUP(A30,'Personal Finance'!A:IV,MATCH(My Details!$H$29,'Personal Finance'!$1:$1,0),0))-4)
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
  • bod1467
    bod1467 Posts: 15,214 Forumite
    edited 10 August 2016 at 12:56PM
    This whole thing would be greatly simplified it you simply put the VLOOKUP formula in a cell/column, set that column to Hide, then used an adjacent cell/column for the LEFT or RIGHT formula.

    Will =RIGHT(Cell,-4) even work? I've never seen the LEFT or RIGHT commands used with negative numbers. The obvious formula would be:

    =LEFT(Cell,LEN(Cell)-4)

    where Cell is the (hidden) cell containing the VLOOKUP.
  • Cotta
    Cotta Posts: 3,667 Forumite
    Thanks very much folks, error has now been corrected.
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 353.5K Banking & Borrowing
  • 254.1K Reduce Debt & Boost Income
  • 455K Spending & Discounts
  • 246.6K Work, Benefits & Business
  • 602.9K Mortgages, Homes & Bills
  • 178.1K Life & Family
  • 260.6K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.