How do I insert specific text into varying places in a string? It is to add details to addresses that are missing.
I'm aware I can use the LEFT and the MID functions to do this, but when the address data varies in length it fails, however it always has to come after "Faketown" in my example.
For example:
Cell A1 may contain
123 Fake St, Faketown, AB1 2CD
Cell A2 may contain
12 TotalFake St, FakeTown, EF3 4GH
I'd like a formula/macro for the column next to it to show:
Cell B1
123 Fake St, Faketown, Fakecounty, AB1 2CD
Cell B2
12 TotalFake St, FakeTown, Fakecounty, EF3 4GH
As you can see it's the addition of "FakeCounty" in the format above that is required. The formula/macro should always put "Fakecounty" after "FakeTown" regardless of how many characters precede FakeTown (otherwise the 'LEFT' and 'MID' functions would be perfect).
I'm certain it's possible, but can anyone point me in the direction I need to go/provide a formula/code that can achieve this?
Related
I have an Excel list with course names and their number like this:
V3 Varikosis Masterclass
B3 Botulinumtoxin Premiumkurs, H2
M1 Mykologie Basiskurs [Digital], D1 Dermatoskopie Basiskurs [Digital]
B5 BTX Workshop (21.11.21) (sometimes there are random numbers that have nothing to do with the code like a date)
It's very messy since some people ordered two courses, so I can't just take the first two symbols from each cell. Is there a formula that finds and extracts a single letter and number combination from a string of text?
If you do not have any other cases e.g. max number of courses is 2 and comma and space is always the same it is rather straightforward.
=LEFT(A3,2)
=IFERROR(MID(A3,SEARCH(",",A3,1)+2,2),"")
Can someone help on this? I have column A with telephone number and Column B with country code. I want to remove the country code in column A if it is there to avoid duplication. Can someone help me?
Column A 1234567 Column B 1 Column C 1234567
Column C should have the formula to check if 1 is already in the beginning of the cell value A, if yes, it'll remove it, but if not, column B value will be added to it. Another scenario is below: Column A 234567 Column B 1 Column C 1234567
Also, I would like to add separators in this formula after the country code, and after three digits of the country code based on column 1 with removed country code in it.
How to append it in this formula?
=IF(B1 = --LEFT(A1, LEN(B1)),A1,--(B1&A1))
Appreciate your answer!
As far as I understand what you describe, you may be after something like this:
="+"&TEXT(B1,"0")&"-"&
IF(LEFT(TEXT(A1,"0"),LEN(TEXT(B1,"0")))=TEXT(B1,"0"),
MID(TEXT(A1,"0"),LEN(TEXT(B1,"0"))+1,99),
A1)
The statement about "after three digits of the country code based on column 1 " is unclear. This formula gives you tools to add characters before and after the country code, while it removes country code duplication.
edit after comments You don't really describe it, at least not clearly, but it looks like you want a vertical bar after the country code and again after the first three digits of the phone number. The formula to achieve that is
=TEXT(B1,"0")&"|"&
REPLACE(IF(LEFT(TEXT(A1,"0"),LEN(TEXT(B1,"0")))=TEXT(B1,"0"),
MID(TEXT(A1,"0"),LEN(TEXT(B1,"0"))+1,99),
A1),4,1,"|")
another edit after stitching together what else you might want but don't clearly describe: If column B can possibly contain either numbers like 1 or 63 but also text that starts with a country code, followed by a space and some other stuff, like 63 2, then you can use this formula
=LEFT(TEXT(B2,"0"),FIND(" ",TEXT(B2,"0")&" ")-1)&"|"&
REPLACE(IF(LEFT(TEXT(A2,"0"),LEN(TEXT(B2,"0")))=TEXT(B2,"0"),
MID(TEXT(A2,"0"),LEN(TEXT(B2,"0"))+1,99),
A2),4,1,"|")
So essentially whats going on is this. I have a list of products in column A.
I want to be able to assign values in column B based on if A1 contains X.
Here are some examples:
If A1 contains Angry Orchard, Redds, or Strongbow, then B1 should say: Apple Beer.
BUT if A1 contains Lite or Light then B1 should say: Light Beers.
BUT If A1 contains Fireball, Absolute Vodka, or Malibu, then B1 should say: Liquor.
This could go on hundreds of times. So I'm thinking I'd go over my nested limit.
I'd really appreciate any help I can get!
I have > 10000 address records in Excel with a range of input patterns but what I want to deal with is this:
|4 example street | (house number, street name but no city)
Is it possible to write a query to fulfil:
if cell begins with a number then append cell with name of city
Can this be done easily in Excel? R? SQL?
Ok, In which case give this a try..
This is assuming that your address data is in cell A1, and you city is in B1. Also I'm assuming you're using excel 2010 or later - I don't think NUMBERVALUE was available pre-2010.
=IFERROR(IF(AND(NUMBERVALUE(LEFT(A1,FIND(" ",A1)))>1,NUMBERVALUE(LEFT(A1,FIND(" ",A1)))<100),CONCATENATE(A1,", ",B1),A1),A1)
The IFERROR will simply display the data in cell A1 if the formula causes an error.
The AND checks the number is between 1 & 100 (change these values as appropriate
The NUMBERVALUE converts the text returned from the LEFT into a number
The LEFT(A1,FIND(" ",A1)) returns all the text in A1 located before the space. Again, this could be changed to a double space, comma, combination of both etc. Just make sure they are in speech marks.
The CONCATENATE puts the data from A1, followd by a comma and space, then adds the city from B1.
So if A1 = '22 John Street', and B1 = 'Bristol', the result would be '22 John Street, Bristol'
and if A1 = '18GreatRoad' (with no space) the result would remain the same as '18GreatRoad'.
How is the address data formatted? Is there a consistent approach to commas/spaces between street name and address? I'm thinking you use =IF(left(A1,2)>0"&<"999,Right(A1,Find(",",A1)-1),FALSE)
Or something to that effect. You could smarten it up to trim spaces or remove junk text by using trim or changing the -1 at the end of the find.
There are two types of values in cell A of my spreadsheet
Value type 1: Have a space in between the postcode district and sub postcode, as the postcode district is less than ten (i.e. MK1-MK9)
MK1 1AS
Value type 2: Have no space in between, as the postcode district is greater than ten (i.e. MK10-MK46)
MK170DB
What would be the best way of splitting the second group of values into something like this:
MK17 0DB
I was thinking of some pseudo code in the the vein of:
if the value at the 4th character (counting from the right) in MK170DB is not an empty space
then count 4 spaces and create an empty character, leaving it like this MK17 0DB
if not then presume that the 4th character is a empty space (i.e. MK1 1AS) and leave it
As I just need to run this operation once to cleanse my data, I was thinking about creating a formula in column B that references column A and does the necessary cleansing. I would then replace the values in col A with what I have in col B.
Can anyone tell me whether the logic I have proposed can be executed in Excel or if there is a better way of doing it?
Thanks.
With your data in A1, in B1 enter:
=IF(ISERROR(FIND(" ",A1)),LEFT(A1,4) & " " & MID(A1,5,999),A1)
Something I came up with, which appears to work...
=IF(MID(A1,4, 1)=" ",A1,REPLACE(A1,5,0," "))