How to append some text to a formula cell? - excel

I have a cell in MS Excel that has this formulas :
=AVERAGE(E2:E165)
How do I make the column display the average followed by " days", i.e. it look like? :
1234 days

Right click on the target cell (or entire column), choose "Format Cells"
On "Number" tab, choose Category: "Custom"
In the text box under "Type:" type:
0" days"
This will have the additional benefit of the VALUE in that cells is still a NUMBER (as opposed to TEXT), and can be used in formulas easily without having to parse out the "DAYS" text like BigBobby's solution ;)

This will append the word days, and also limits the # to 3 decimal places.
=CONCATENATE(ROUND(AVERAGE(E2:E165), 3), " days")

Related

change date format m/d/yyyy to dd/mm/yyyy using formula

sr date date-text mm dd yyyy concat(dd,mm,yyyy)
1 12/31/2018 12/31/2018 12 31 2018 31/12/2018
2 3/31/2019 3/31/2019 3/ 1/ 2019 1//3//2019
as shown above i have some dates in col 'date' formatted as m/d/yyyy. i need to convert this to dd/mm/yyyy. i tried DATEVALUE funtion but it gives value error as my pc date format is dd/mm/yyyy. Unfortunately i cant change my PC date format.
So i tried to split the date using LEFT,MID and RIGHT function.
date-text = TEXT([#[date]],"mmm/ddd/yyyy") - to fix date format to mm/dd/yyyy
mm =LEFT([#[date-text]],2)
dd =MID([#[date-text]],4,2)
yyyy=RIGHT([#[date-text]],4)
concat(dd,mm,yyyy) = =CONCAT([#dd],"/",[#mm],"/",[#yyyy]) to get mm/dd/yyyy for mat.
This approach works for row 1 but for row 2 i get wrong date "1//3//2019". please let me know how to fix this
Try following formula
=DATE(RIGHT(A1,4),LEFT(A1,SEARCH("/",A1)-1),TRIM(MID(LEFT(A1,SEARCH("/",A1,SEARCH("/",A1)+1)-1),SEARCH("/",A1)+1,2)))
You can get the result you want with just one formula:
=DATE(VALUE(RIGHT(A2;4));VALUE(MID(A2;1;FIND("/";A2;1)-1));VALUE(MID(A2;FIND("/";A2;1)+1;FIND("/";A2;FIND("/";A2;1)+1)-FIND("/";A2;1)-1)))
I understand very well your situation. I'm from Portugal and here we have the same date format as you (dd/mm/yyyy). Pay attention to your pasted values as a "date". For instance, if you place 3/31/2019 Excel won't recognize it as a date and paste it as text (that's why you don't need your date-text column). However, if you paste 1/12/2019 Excel will write automatically 01/12/2019 when the true date is 12/01/2019 and the formula will not work.
Simplest way for me is to use text to column function. select m/dd/yy dates and go to "Data" select text to column function located in "data tools". This enables the Text Wizard - select the delimited button. hit "next". Step 2 wizard box appears which is where you choose your delimiters. remove any ticks except for "Other" and tick this box. Click "Next". Step 3 of 3 box appears. IMPORTANT Choose your destination carefully. Ideally select a blank cell at the end of your existing data. In this way the results of the text to data function can be freely edited. If you have selected your original data correctly every cell will transpose as m - dd - yyyy. Cut and paste the year to its RH adjacent column and transpose the "m" to the blanks cells that were occupied by the "yyyy". Now you'll have 3 columns "dd", "mm", "yyyy". with a Blank column where the "m's" were. Select the blank cell to the left of the first row of transposed data. Enter the formula "=VALUE(ddcell&"/"&"mm"cell)
you should get a result of 1/01 (if that's the date your modifying). If the current year is 2022 then that will be added automatically. If not you'll have to modify your formula to include the date you want. If the result shows just a number go to your home tab and then number options. Select "Short Date" and it will all happen. With some practice this procedure is a breeze and saves writing those long messy formulas.
Good luck from Henry

How to format numbers to be stored as text in excel?

In excel I have many cells of number in a column formatted as text. I want to convert them into a formatting "number stored as text". I can do it for a single cell at a time by putting an apostrophe (') before the number and pressing enter. My problem is how to achieve this type of formatting for rest of the cell quickly. I have tried to create a new column as ="'"&A2 and copy, but it does not work.
In the attached figure I have converted cell A2 as number formatted as text by putting an ' before it and want to do the same for rest of the cell quickly.
While it may not be the fastest solution, just select the cells you want to be text and set the formatting to text => hit alt + F11
In the "Immediate" window run:
for each x in selection.cells: x.value = format(x.text,"'#"): next
You can do this with a helper column.
You'll need to know what the numberformat was before you formatted the column as text. Then just use that same format in this formula:
=TEXT(A1,"number_format")
eg:
=TEXT(A1,"General")
or
=TEXT(A1,"0")
Fill down as far as necessary.
Next, select the cells in the column with the formula and Edit-Copy; Edit-Paste Special Values This will replace the formula with the text result.

Formatting Excel-Formula

I have made an excel formula that will take the data entered into column O and then multiply it by .04 and then input that data into column P. So I can calculate a four percent fee from the original number. I am now left with a bunch of $0.00 in every row in the P column that lacks data in the O column. I understand this is because 0*.04 = 0. But what I was wondering is if there was a way to make it so that if the total in column P was less than $0.01 or equivalent to $0.00 that the cell would remain blank.
I tried to post an image to show exactly what I am talking about, but I do not yet have the reputation. Hopefully you can understand what I am trying to do based off what I typed.
Do conditional formatting of the cell such that if the value = 0, the number type is "general"
Then, in your formula for the cell itself (assuming you multiply C3*B3), you can do this:
=IF(C3*B3>0,C3*B3,"")
This will use number formatting for all values that are non-zero, but empty string "" with general formatting for zero values.
Method 1:
Select the cells with the percentages in column P and tap Ctrl+1. When the Format Cells dialog opens, go to the Number tab and choose Custom from the list down the left. Supply the following in the Type: textbox.
$#,##0.00;;;
Click OK in the lower right.
Method 2:
Go into Excel Options (Alt+F,T) and choose Advanced from the list down the left. Scroll the right pane down to the Display options for this worksheet section and uncheck Show a zero in cells that have a zero value. Click OK in the lower right.
You can use conditional formatting when the value is less than 0.01 make the font white
The cell will still be 0 but not visible
Try this: =IF(O2<0.01,"",O2*0.04). This particular formula is checking to see if cell O2 is less than 0.01, and if so is filling in the P2 cell with a zero-length string. If O2 is equal or larger than 0.01 it will multiply by .04 and put that result in cell P2.

Dynamic data validated drop down list

I am using VBA but I don’t mind using something else!
I have a table with 2 columns
Col A - Heading "RP" with 20 rows begining with "Rept Pd 1" down to "Rept Pd 20"
Col B - Heading "Claims Months", each cell a data vlidated list "0 Months" to "9 Months".
A seperate cell with "Total Months".
Background: Above table is to split reporting for a project into claims months. Maximum possible number of reporting periods (RP) is 20 and minimum is 1. Claims months can range from 0 Months to 9 Months. The total number of Months is hard keyed in, based on the figure in Total Months the ‘Claims Month’ cells for each ‘Rept Period’ should list in a drop down the number of possible Months.
E.g. If the Total Months were 24 and I were to select the Claims Months for ‘Rept Period 1’ to 20 months then ‘Rept Period 2’ should give me a list between 0 Months and 4 Months. If I selected 1 Month for 'Rept Pd 2' then drop down option for claims months for 'Rept Pd 3 should be 0 Months to 3 months and so on.
Hope that makes sense!
Many thanks
Byron is right that you should limit the selections to the numbers only. I'll add some extra steps for if you really want to have the " months" included, but this makes the whole thing even more difficult and space consuming.
What you will need to do is:
1) Assuming you have the Total Months value is in J1, and that the individual Claim Months are specified in Column I, add this formula =J1-SUM(I:I) to another cell in the same worksheet (I'll assume K1 is used). NOTE: The Total Months & the Claim Month selections should NOT be in the same column.
2) Fill enough rows of one column with this formula: =IF(ROW()-1<=K$1, ROW()-1, "") so that you cover the largest possible Total value. Ex. if you'll never have a Total Months>100, the formula should be in rows 1-100. I'll assume you use column L, so adjust accordingly.
3) In another, out-of-the-way cell add the formula =COUNT(L:L). I'll assume you use N1.
4) You now need to create a named range. To do that, go to the Formulas portion of the ribbon and click "Name Manager". In the window that opens, click "New". Add any name that suits your purposes (no spaces or special characters, except underscores), set "Scope" to the worksheet you're on, and in "Refers to:" enter this formula =OFFSET($L$1, 0, 0, $N$1, 1). Add a comment if you like, and then click "OK".
5) Highlight the rows that you want to use for the Claim Months values and open the Data Validation window. Select "List" in the "Allow" field, and in the "Source" field type = and hit F3. In the "Paste Name" window that appears select the Named Range we created and click "OK". Click "OK" in the Data Validation window as well.
Optional
6) Add this formula =IF(L1="", "", CONCATENATE(L1, " months)) to the column next to the one we added formulas to in Step 2. Drag that formula to cover the same rows we used in Step 2. I'll assume Column M is used for this formula
7) Adjust the formula in the Named Range we created in Step 4, so that $L$1 is replaced with $M$1
8) In another column (I'll use column H) add this formula =IF(I2="", "", VALUE(LEFT(I2, LEN(I2)-7))) and have this formula appear next to each Claim Month selection cell.
9) Update the formula from Step 1 to replace I:I with H:H
You should be set.

How to zero fill a number inside of an Excel cell

How do you zero fill a number to 10 positions inside an excel spreadsheet?
i.e. If cell A1 has 1234 how can cell A2 display 0000001234 (10 postions).
=TEXT(A1,"0000000000")
Not a programming question, really:
Select cells you want formatted in this way.
Right click and select "Format Cells..."
Select the "Number" Tag, and scroll down to "Custom" in the category list.
Type "0000000000" into the Type field.
Format>Cells...>Number>Custom>Type>0000000000
This formula is variable.
It checks the length of the value and add "0" in front
Now the lenght is 10. You can change it.
=REPT("0",10-LEN(A1))&A1
I know this is a pretty old post, but I've just came across the same problem while exporting a sql table to excel, and I found I very simple solution!
Just set the cell format to ' Custom' then type the amount of characters you want the final number to have;
In your case 10 positions '0000000000'
I don't usually reply to the stackoverflow's posts, so I don't have enought reputation to post images;
Something like the following.
right( "0000000000" & number, 10 )
Put 10 zeroes on the left, take the right-most 10 positions, whatever they turn out to be.
Also, you have
text( number, "0000000000" )
How to display full the number inside in excel workseet?
I.e cell A1 "2.40252E+13" how to display full number in A1 became "24025207702012"

Resources