How to combine specific letters and numbers from different cells in Excel? - excel

I have 3 names that I want to combine to create something unique - I've used "CONCATENATE", but to no avail.
Example:
Paper (will always be different)
000001 (This will be sequential, the next row will have 000002)
Plastic (will always be different)
Essentially I want to input all three items in different cells and have the fourth cell output the following:
Pa000001Pl
Thank you.

Using & between objects is an alternative way to concatenate in excel:
=LEFT(A1,2) & B1 & LEFT(C1,2)
See http://fiveminutelessons.com/learn-microsoft-excel/extract-text-cell-excel for info on how to extract text from cells. (Examples: LEFT(), RIGHT(), MID(),FIND().
See https://support.office.com/en-za/article/Combine-the-contents-of-multiple-cells-3a86c317-6b91-4f1d-8781-203320aefdce for info on how to combine text from cells.
If you want to keep the 00000's in the number you need to make sure to format the cells containing the numbers as Text.
You could do this using the TEXT() function on the fly:
=LEFT(A1,2) & TEXT(B1,"000000") & LEFT(C1,2)
The six 0's tell Excel to create a number 6 digits long and replace any 0 with a non-zero number from your cell. So if B1 is 1, TEXT(B1,"000000") will convert it to 000001. If B11 is 11, TEXT(B11,"000000") will convert it to 000011.
If you instead want to ensure that the same number of 0's remain in front of your non-zero numbers, you could use the CONCATENATE() function:
=LEFT(A1,2) & CONCATENATE(B1,"00000") & LEFT(C1,2)
This would always insert five 0's in front of whatever number is listed in B1.

With values in A1, B1, and C1, in another cell enter:
=LEFT(A1,2)&TEXT(B1,"00000")&LEFT(C1,2)
This is needed to preserve the leading zeros if those leading zeros are the result of formatting cell B1

Assuming your values are in the 2nd Row
=LEFT(A2,2) & B2 & LEFT(C2,2)

Related

Count the number of existence of a specific number

I have multiple cells which have number separated by columns and want to count the number of existence of a specific number. How may I count the number. what will be the formula.
I have data like in picture and want to count the existence of 1 or any other number in all highlighted cell. I used the countif formula to count the number 1 but it also counts it for 11 or 12.
If anyone have any Solution.
Thanks
enter image description here
I would try and restructure your data so it's easier to work with. Otherwise, here's a dirty solution:
You could first add a comma before and after all your cells with "," & cell & "," so all numbers are separated by a comma, including the last one. Then use COUNTIF to count numbers, by looking for eg. *,1,* or *,12,*:
Orginal
="," & A1 &","
=COUNTIF([your cell range];"*,1,*")
1,2,10,11,12
,1,2,10,11,12,
4
1,2,10,11,12
,1,2,10,11,12,
1,2,10,11,12
,1,2,10,11,12,
1,2,10,11,12
,1,2,10,11,12,

Count number of comma separated values, divide next cell by that number?

I have a table in which one column occasionally contains a sequence of numbers separated by commas (Units). I'd like to find a script that will count the amount of values in that cell (Values), then divide the adjacent cell by that amount, ultimately replacing the value of that cell (NeedResult, replacing Values).
I've played around with formulas, but my VBA skills are rudimentary... Any help mucho appreciated!
table image here
Unless you really want it, I'm not sure you need a VBA solution for this. The calculation can be done using Excel's formulas: simply subtract the length of the string from the length of it with commas removed. Your cell formula could look something like this:
=C3/(LEN(B3)-LEN(SUBSTITUTE(B3,",",""))+1)
Split the first cell value on the commas and adjust the ubound dimension of the resulting array.
dim i as long
i = ubound(split(range("b2").value, chr(44))) + 1
range("d2") = cdbl(range("c2").value / i)
Without the compiler directive Option Base 1, a split array is zero-based.
You could use a formula as well
In D2 entered as array formula with Ctrl+Shift+Enter
=IF(ISBLANK(B2),"",C2/COUNT(FILTERXML("<t><s>" & SUBSTITUTE(B2,CHAR(44), "</s><s>") & "</s></t>", "//s")))

How to string two numbers together with extra zeros

How can I make a cell A1 "1234" with cell A2 "27" to make 12340027 as a number not text. In short, numbers in A2 are 1, 2 or 3 digits in length but they must be formatted to 4 digits e.g. 27= 0027, 4=0004. Using TEXT is resulting in lookup functions not working
How about:
=A1*10^4+A2
Just adds 4 zeros to the end of A1 and then adds A2 to it.
#keatz also elegant answer
If I got you correctly,
you can achieve it by this formula:
=CONCATENATE(A2,RIGHT(B2/10000,4))*1
Wrap your formula in VALUE() to turn the text back to a number:
=VALUE(A1 & TEXT(A2,"0000"))
Or multiply the text by one (or add zero):
=(A1 & TEXT(A2,"0000"))*1

Stuck combining 3 numbers

I need a formula in Excel, not VBA please, forbidden to have such functions on my work machine. My situation is I need a number from cell A, which is a result from Today(), combined with a number from cell B, which is a result from Now(), combined with a number from cell C which is a text number, to output as a single number.
Example:
Cell A1 Cell A2 Cell A3
Formula: TODAY() NOW() 17709
Displays: 1011 1423 17709
Needed: 1011142317709
What I'm trying is this, which is a fail: =TEXT(O21,yy-mm)&""&TEXT(P21,hh,mm)&"""&VALUE(Q21)
=TEXT(O21,"yymm")&""&TEXT(P21,"hhmm")&""&VALUE(Q21)
Placed in quotes the number format and removed extra quote though not sure why you are adding null to the string.
To match the sample output OP provided the formula would be:
=TEXT(A1,"mmdd")&""&TEXT(B1,"hhmm")&VALUE(C1)
If you do not need leading zeroes to fill 5 digit placeholders for the value in Q21,
=TEXT(NOW(),"yymmhhmm")&TEXT(Q21, "0")
'possibly,
=TEXT(NOW(),"mmddhhmm")&TEXT(Q21, "0")
If you do need leading zeroes to fill 5 digit placeholders for the value in Q21,
=TEXT(NOW(),"yymmhhmm")&TEXT(Q21, "00000")
'possibly,
=TEXT(NOW(),"mmddhhmm")&TEXT(Q21, "00000")

Extract two numbers out of a string in Excel

I have a string that I need two numbers extracted and separated into two columns like this.
ID:1234567 RXN:89012345
ID:12345 RXN:678901
Column 1 Column 2
1234567 89012345
12345 678901
The numbers can be varying number of characters. I was able to get column 2 number by using the following function:
=RIGHT(G3,FIND("RXN:",G3)-5)
However, I'm having a hard time getting the ID number separated.
Also, I need this to be a function as I will be using a macro to use over many spreadsheets.
A way to do this is:
Select all your data - assuming it is in a string all the time - which means one cell has one row with ID&RXN nos. So if you have 100 rows such data, select all of it
Go to the Data tab, Text to columns
Choose Delimited>>Next>> choose Space here, in Other, type a colon(:) >> Finish
You will get "ID" in first column, every cell; ID no in second column every cell; RXN in third column every cell and RXN no in 4th column every cell.
Delete unwanted columns
With data in column A, in B1 enter:
=MID(A1,FIND("ID:",A1)+LEN("ID:"),FIND(" ",A1,FIND("ID:",A1)+LEN("ID:"))-FIND("ID:",A1)-LEN("ID:"))
and copy down. In C1 enter:
=MID(A1,FIND("RXN:",A1)+LEN("RXN:"),9999)
and copy down:
The column B formulas are a pretty standard way to capture a sub-string encapsulated by two other sub-strings.
If your format is always as you show it,then:
B1: =TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1," ",REPT(" ",99)),":",REPT(" ",99)),99,99))
C1: =TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1," ",REPT(" ",99)),":",REPT(" ",99)),3*99,99))
We substitute a long string of spaces for the space and : in the original string. Then we extract the 2nd and 4th items and trim off the extra spaces.

Resources