Excel Reference Cells Up to Number of Characters Until Last Space - excel

I have a cell that is referencing multiple different cells and I want it to reference one more cell at the end that will fill the rest of the space up (up to 80 characters).
Example: Cell AA2 (cell I want to fill up) contains: =B2&" OEM "&D2&" replacement "&LOWER(LEFT(TRIM(X2),FIND("~",SUBSTITUTE(X2," ","~",LEN(TRIM(X2))-LEN(SUBSTITUTE(TRIM(X2)," ",""))))-1))&" "&LOWER(T2)
Cell Z2 contains: 582146-01 BDEMS600 MS500CBGB MS525B MS800B
I want to add the contents of Z2 to the end of AA2 but only until AA2 has 80 characters and I don't want just part of one of the items in Z2. Another thing is I want to do this starting from the end of cell Z2 so let's say 582146-01 and BDEMS600 might get cut off to make it 80 characters. Is this possible? Thanks for the hlep!

Related

How to retain A1 Notation in Excel fill after being dragged down for every row?

How do I retain the value of A1 Notation after I drag it down to copy the formula to other rows?
For example, I have 2 columns, A and B, and let's say 10 rows, 1-10
And the formula is =(A1)&"randomtexts"
I want the basic A1 notation (I'm not sure what it's called, please let me know what) and make it fixed in that formula so that it wont become A2, A3, A4, etc.. down the line?
I need it to be fixed A1, for this specific problem. Is there a word I can add to indicate it should always be A1 (or any specified cell) and not change it automatically?
Use the $ like:
=A$1 & "whatever"
when copied downward the 1 will not advance to 2, 3, etc.
(by the way, it is called "A1" notation)

Extract chacters from a cell with dynamic attribtutes

I will try my best to make this as simple of an explanation as possible.
Cell A1 contains a series of data looking like:
X001DDWIQ3(607093),X001E6Y98T(81299),X001E6Y98T(81299),X001DDWIQ3(607093),X001R5N087(605253),X00185UHG9(439599),X00185UHG9(439599),X001RPL9AN(37),X001PBDU9R(101),X0017I5MV7(439599)
Cell B1 is similar and has corresponding data:
CAE1,CMH1,DFW7,EWR4,MKC6,MKE1,OAK4,ONT2,SNA6
Cell C1 contains one value from Cell B1
EWR4
Since EWR4 is the 4th item in Cell B1 then it coordinates with X001DDWIQ3(607093), the 4th item in cell A1.
Since all of the items in B1 are 4 characters long separated by a comma and no spaces I can use the formula:
LEN(LEFT(A1,FIND(C1,B1)-1))/5+1
to determine the position in B1 that C1 occupies.
What I am trying to do is extract the corresponding value into Cell D1. The only constant information I can extract from what I have now is that the desired value is located between the 3rd and 4th comma, and the characters outside of the parenthesis always have a count of 10. The number in the parenthesis is dynamic, and that is what is stumping me.
I need to determine how many characters up to the 3rd comma and the 4th comma to utilize as my start and stop points for an =MID.
Your LEN(LEFT(A1,FIND(C1,B1)-1))/5+1 can be simplfied to:
(FIND(C1,B1)-1)/5+1
Then we can use that in a mid that adds 99 spaces for every , which gives us a large target to find. Then we trim the return.
Use:
=TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",99)),((FIND(C1,B1)-1)/5)*99+1,99))

(Excel 2013) Combining two cell value without exceeding certain characters limit

I've tried to solve this with excel formula but it is too complicated as I need the workbook to be as less clustered with formulas. So I turned to VBA for aid. So far all the VBA that I've found was mainly for trimming single cell characters only.
What I need for my project is as follows:
A1-Name
B1-Colour
C1-Name(Colour)
If LEN(C1) is less than 81 then nothing is trim. Else, TRIM A1 only without changing B1 so the end result is LEN(C1) is always less than 81.
Thanks.
Edit:
Excel Screenshot 1
What I've tried is:
-I will do "len" on B2 in cell AA2 then another "len" on C2 in cell AB2.
-Then I combine B2 and C2 in cell D2.
-Do another "len" for cell D2 in cell E2.
-If the value in E2 exceed 80, then I've to do "right" for cell B2 in another cell.The value that will be deducted from cell B2 is AA2-80+AB2.
-Once it is done, the new trim B2 will be recombine with C2 in another cell.
That is too many new cells. As you can see, I've to hide some cells that make up what is inside cell F2. So here I am. Beaming up that spotlight with that letter "E" so that Excelman will come to the rescue.
A very simple Excel formula which should do what you want is
=LEFT(A1,MAX(0,78-LEN(B1))) & "(" & B1 & ")"
i.e. take as many characters as possible from A1 so that, when concatenated to "("&B1&")", the total won't exceed 80 characters, and then concatenate that to the "("&B1&")".
Note: Cell references in the formula above are based on your original question. Based on the screenshot, and the edits to your question, the formula would be:
=LEFT(B2,MAX(0,78-LEN(C2))) & "(" & C2 & ")"
If you definitely need VBA, you can use the same functions (i.e. Left and Len) and the same operators (i.e. - and &) in VBA as are used in Excel. The only problem is MAX, which will need to be replaced with Application.Max or with an If statement.

How to merge two cells, add a space and a comma

I have two cells:
Cell 1 - Toronto
Cell 2 - ON
I want to merge into one cell and have it say Toronto, ON (adding a , and space after Toronto).
Assuming Cell 1 is A1 and Cell 2 is B1, please try:
=A1&", "&B1
I think you want to CONCATENATE rather than merge (which is best avoided at all costs).
An alternative version is:
=CONCATENATE(A1,", ",B1)

Format if cell partially matches another

I have two columns with telephone numbers in them, I want cells B2 and B3 to change colour depending on whether they match the last 4 digits in the column next to them:
B2 turns green as it matches the end of A2 and B3 turns red as it does not match the last four digits of A3.
How would I go about doing this?
I suggest you just use one rule, say format all red and use the CF to change that to green only when there is a match, say with:
=B1=VALUE(RIGHT(A1,4))
in B1 and applied to B:B.

Resources