I've a huge data in excel file.
For eg: say i've a word like paul son,i've to make it as paulson.
input:paul son
output:paulson.
In some cells ,i've data like mic-li,when this type of words come,it should not replace any thing,it should only remove spaces in between words.
Suppose the data is in the B column, write in the C column the formula:
=SUBSTITUTE(B1," ","")
Copy&Paste the formula in the whole C column.
edit: using commas or semicolons as parameters separator depends on your regional settings (I have to use the semicolons). This is weird I think. Thanks to #tocallaghan and #pablete for pointing this out.
It is SUBSTITUTE(B1," ",""), not REPLACE(xx;xx;xx).
Steps (1) Just Select your range, rows or column or array ,
(2) Press ctrl+H , (3 a) then in the find type a space
(3 b) in the replace do not enter anything,
(4)then just click on replace all.....
you are done.
Just wanted to add on to vulkanino's answer... now 10 years later ha. This is what I was looking for maybe someone else is too. You can also build on multiple =SUBSTITUTE() functions.
Here is what I used to format a list of names for Active Directory accounts. B2 is where the name would go. I wanted to change the space between the First name and last to a period and omit any hyphens from names.
=SUBSTITUTE(SUBSTITUTE(B2, " ", "."), "-", "")
For example the line above would look like this:
First Last-Name => First.LastName
, "-", "")
This part removes the hyphen.
(B2, " ", ".")
This part selects the cell to modify and changes empty space to a period.
=SUBSTITUTE(SUBSTITUTE(...)...)
I used two substitute functions one inside the other.
Related
I found a lot of formulas on the Internet which copies "n characters" but they did not provide a solution for me. I am searching for a VBA code which is able to move the specific value from a column to the beginning of adjacent column. For example, the VBA code will check the A column for the word "Warm" and "Cold", and if they are available, it will move them as shown in the example. Thank you in advance for your help.
Example
Edit ( Solution by #Dominique ): =IF(A1<>"";IF(RIGHT(A1;4)="Warm";"Warm "&B1;B1))
You can't move a part of one cell to another. This is what you need to do:
Search for " Warm" (or " Cold") in a cell in column A and replace " Warm" (or " Cold") by an empty string within that cell.
Take the cell, next to that (use the Offset() function) and add the word "Warm " (or "Cold ") at the beginning of that cell.
Do this for the entire A column.
I want Excel (or Linux command) to change the string of values.
From:
e.g. column A
IN_EMAIL.201_101300_180403_131131_6160_5593
To:
e.g. column B
EMAIL.201_101300_0_180403_131131616_0000_5593
So:
Remove "IN_"
Add "0_" after 20th character
Remove "_" after 33rd character
Add "_000" after 37th character
I've got two formulas. How can I nest them into one?
=REPLACE(REPLACE(A4;1;3;"");18;0;"0_")
=REPLACE(REPLACE(B4;33;1;"");36;0;"_000")
It is solved,
=REPLACE(REPLACE(REPLACE(REPLACE(A11;1;3;"");18;0;"0_");33;1;"");36;0;"_000")
If you want to combine these two formulas:
=REPLACE(REPLACE(A4;1;3;"");18;0;"0_")
=REPLACE(REPLACE(B4;33;1;"");36;0;"_000")
Just replace B4 with the first formula
=REPLACE(REPLACE(REPLACE(REPLACE(A4;1;3;"");18;0;"0_");33;1;"");36;0;"_000")
Alternatively you could use the following formula that might be more obvious:
=MID(A5;4;17) & "0_" & MID(A5;21;13) & MID(A5;35;3) & "_000" & RIGHT(A5;6)
Good morning, I was looking for a formula to help me with this in Excel 2016, but I did not succeed, I have this text in a cell:
CF|0101|2019-02-05|01|F007-00000018|PEN|20539043782|6|20479636304|SERVICENTRO SANTA MARIA EIRL|CARRET. JAEN SAN IGNACIO KM 25- CAS. YANUYACU- JAEN||||||||6.10|33.90|6.10|0.00|0.00|0.00|0.00|0.00|0.00|0.00|0.00|0.00|0.00|0.00|33.90|40.00|0.00|0.00|40.00|1000|CUARENTA CON 00/100 SOLES |||||||M5K-788|
I want to extract the text with the help of the separator "|" and in a not so long formula, try with FIND, but the formula becomes very long after the third linked search, is there any way to obtain the position of the separator by number of concurrency? , something like this:
Searched text;Cell;Repetition number(concurrency of simbol)
=FORMULA("|";A1;2)
Result: 8
Or simulate something like this?
From already thank you very much.
**UPDATE
I will not use all the texts among the "|", that's why my need to obtain the position of the separators to extract only the text I need, since the tool "Text to Columns "forces you to give a position for all the separate texts.
If you truly want a formula that will separate everything into unique Columns. Then perhaps you should look at a custom formula. Here is a quick example of UDF that can parse data based on the "|"
Function SplitData(rng As String, Character As Variant, Position As Integer) As Variant
SplitData = Split(rng, Character)(Position - 1)
End Function
Once this function has been placed into a VBA module, then you can call this from any cell within that workbook.
To keep things simple here is the breakout...
=SplitData( <THE CELL THAT CONTAINS THE DATA YOU WISH TO PARSE>, <THE CHARACTER YOU WANT TO USE AS YOUR DELIMITER>, <POSITION IN WHICH YOU WANT TO DISPLAY THE TEXT (Valid Numbers start at 1+> )
The POSITION Point is used to display which section of the text. For example based on your example provided, if you populated the following...
=SplitData(A1, "|", 1) == "CF"
By the way, if you are dead set on finding the location of the "|", then how about using the =Search() formula. This will easily hunt do the character position of the first "|", but with a little bit of work you can get it to display other locations.
As outlined here, you can use Text to Columns:
Select the cell or column that contains the text you want to split.
Select Data > Text to Columns.
In the Convert Text to Columns Wizard, select Delimited > Next.
Select the Delimiters for your data. You'd want to put a | in the "Other" area.
Select Next.
Select the Column data format or use what Excel chose for you.
Select the Destination, which is where you want the split data to
appear on your worksheet.
Select Finish.
Or - if you literally just need all that in a single string, without |, you can use SUBSTITUTE():
=SUBSTITUTE(A1,"|"," ")
I have a CSV in which column A is populated with strings, such as:
ABCDE/FGHI/JKL/MNOPQR
I need to populate column C with everything after the last occurrence of the "/". In this example, it would have to be "MNOPQR".
Is there a function that could be used for this? "RIGHT" doesn't seem to do the trick. I don't know what the length of the substring will be in each row, so I definitely have to look for the "/".
If your text is in A4, put this in another cell:
=MID(A4,LEN(LEFT(A4,FIND(CHAR(1),SUBSTITUTE(A4,"/",CHAR(1),LEN(A4)-LEN(SUBSTITUTE(A4,"/",""))))))+1,LEN(A4)-LEN(LEFT(A4,FIND(CHAR(1),SUBSTITUTE(A4,"/",CHAR(1),LEN(A4)-LEN(SUBSTITUTE(A4,"/",""))))))+1)
I think that should work. Thanks to #Jerry for the main part, where it finds the last / in a string.
edit:
Per #ScottCraner, this is shorter: =MID(A1,SEARCH("}}}",SUBSTITUTE(A1,"/","}}}",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))))+1,LEN(A1))
Here's a bit shorter formula to return the last delimited substring in a string.
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",99)),99))
Replace the delimiter with 99 spaces, then return the rightmost 99 characters. The leading characters must be spaces also, so TRIM gets rid of them.
A simple formula approach using FilterXML might be:
=FILTERXML("<items><i>" & SUBSTITUTE(A1,"/","</i><i>") & "</i></items>","//i[position()=last()]")
Profitting from the dynamic features of vers. 2019+ you can change the cell address to a range input, e.g. A1:A10 allowing output in a so called spill range.
VBA approach
As the VBA tag has been recently added to OP,
an obvious VBA approach would be to split the string input and get the last array element via Ubound():
Dim tmp As Variant
tmp = Split("ABCDE/FGHI/JKL/MNOPQR", "/")
Debug.print tmp(Ubound(tmp)) ' ~~> MNOPQR
I have a column with some text in each cell.
I want to add some text, for example "X", at the start of all cells. For example:
A B
----- >>>> ----
1 X1
2 X2
3 X3
What is the easiest way to do this?
Type this in cell B1, and copy down...
="X"&A1
This would also work:
=CONCATENATE("X",A1)
And here's one of many ways to do this in VBA (Disclaimer: I don't code in VBA very often!):
Sub AddX()
Dim i As Long
With ActiveSheet
For i = 1 To .Range("A65536").End(xlUp).Row Step 1
.Cells(i, 2).Value = "X" & Trim(Str(.Cells(i, 1).Value))
Next i
End With
End Sub
Select the cell you want to be like this,
Go To Cell Properties (or CTRL 1)
under Number tab
in custom
enter
"X"#
Select the cell you want to be like this, go to cell properties (or CTRL 1) under Number tab in custom enter "X"#
Put a space between " and # if needed
Select the cell you want,
Go To Format Cells (or CTRL+1),
Select the "custom" Tab, enter your required format like : "X"#
use a space if needed.
for example, I needed to insert the word "Hours" beside my numbers and used this format : # "hours"
Enter the function of = CONCATENATE("X",A1) in one cell other than A say D
Click the Cell D1, and drag the fill handle across the range that you want to fill.All the cells should have been added the specific prefix text.
You can see the changes made to the repective cells.
Option 1:
select the cell(s), under formatting/number/custom formatting, type in
"BOB" General
now you have a prefix "BOB" next to numbers, dates, booleans, but not next to TEXTs
Option2:
As before, but use the following format
_ "BOB" #_
now you have a prefix BOB, this works even if the cell contained text
Cheers, Sudhi
Michael.. if its just for formatting then you can format the cell to append any value.
Just right click and select Format Cell on the context menu, select custom and then specify type as you wish... for above example it would be X0. Here 'X' is the prefix and 0 is the numeric after.
Hope this helps..
Cheers...
Go to Format Cells - Custom. Type the required format into the list first. To prefix "0" before the text characters in an Excel column, use the Format 0####. Remember, use the character "#" equal to the maximum number of digits in a cell of that column. For e.g., if there are 4 cells in a column with the entries - 123, 333, 5665, 7 - use the formula 0####. Reason - A single # refers to reference of just one digit.
Another way to do this:
Put your prefix in one column say column A in excel
Put the values to which you want to add prefix in another column say column B in excel
In Column C, use this formula;
"C1=A1&B1"
Copy all the values in column C and paste it again in the same selection but as values only.
Type a value in one cell (EX:B4 CELL). For temporary use this formula in other cell (once done delete it). =CONCAT(XY,B4) . click and drag till the value you need. Copy the whole column and right click paste only values (second option).
I tried and it's working as expected.