I want to format all cells of a column. The data is a number and I want to add a decimal from left keeping only two digits after that. Then format it as per currency standards. For eg:
Data: Output:
10000 100.00
112233 1,122.33
123456789 1,234,567.89
The requirement is normal and output is in italics.
The following will format a given column as Currency:
Sheets("Sheet1").Columns("A").NumberFormat = "£#,##0.00"
Macro recorder is a bit dangerous in this case, because if you use it, your code would look like this (from the other answer):
Sheets("Sheet1").Columns("A").NumberFormat = "£#,##0.00"
However, this is only ok in UK. If you want to write code, which formats currency based on the local settings of the PC, then it is a good idea to use the currency there:
Sheets("Sheet1").Columns("A").Style = "Currency"
Then a UK person would get pounds format and a US one dollars.
If I display a date in cell A1 using the cell format [$-8040D] d to show the day of the jewish month, I get a number (from 1 to 30) instead of -the way it is normally displayed- a hebrew letter.
So I want to use
=CHOOSE(A1,"א","ב","ג","ד","ה","ו","ז","ח","ט","י","יא","יב","יג","יד","טו","טז","יז","יח","יט","כ","כא","כב","כג","כד","כה","כו","כז","כח","כט","ל")
But even though I see a number 1-30 displayed in A1, what's really there is a date serial code (something like "44181").
I have tried N(), and VALUE().
What's the correct way to do it?
Thanks!
Excels stores dates numbers as per the Gregorian calendar with 1 = 1 Jan 1900 (and 1900 erroneously being deemed a leap year for competitive reasons).
So first you need to convert the date to the Jewish date (I'm assuming the Jewish Lunar calendar); extract the day of the month(with the TEXT function), and then convert that value to its Hebrew letter equivalent.
eg:
=CHOOSE(TEXT(A1,"[$-he-IL,8]dd"),"א","ב","ג","ד","ה","ו","ז","ח","ט","י","יא","יב","יג","יד","טו","טז","יז","יח","יט","כ","כא","כב","כג","כד","כה","כו","כז","כח","כט","ל")
or:
=CHOOSE(TEXT(A1,"[$-8040D]d"),"א","ב","ג","ד","ה","ו","ז","ח","ט","י","יא","יב","יג","יד","טו","טז","יז","יח","יט","כ","כא","כב","כג","כד","כה","כו","כז","כח","כט","ל")
So for today which is
the formula would return
The "correct" way to do it is to realize there is no problem here, no problem at all.
Yes, Excel uses a serial number dating system. However, it completely knows how to interpret it too. So you will have a serial number as the "real" content of A1, but can extract from it the day of the month value. You can do this with:
=TEXT(A1,"d")
This gets you a TEXT "6" if it is December 6. Often that fact (that it returns TEXT) can cause trouble. But only when Excel could expect you could mean either and has to guess which. In the case of the above formula it would be reasonable for it to assume you wanted it looked at as text since the function is... TEXT()...
But in this case, using it in the CHOOSE() function it can ONLY be useful if Excel treats it as a value rather than text. So it does. No need to add anything to force Excel to do so.
So you can just replace the A1 portion of your formula with the above TEXT() function. Then Excel will use it properly and select the correct day of the month from the list.
And that's all you need.
I have various peoples' DOBs. I want to convert them to a format that will serve as their predicted-but-incomplete NY Driver's License expiration date (which is always the person's DOB in some later year). Because (for now) all of the license expiration dates will be sometime before 2030, I would like to essentially chop off the year portion of the DOBs and replace them with "202_" (or if that's not feasible then just "202").
I know how to get Excel to display the DOB without the year, but that isn't helping me so far. My hope had been to use CONCAT to start with that truncated display and then just add "202_" but the date format of the truncated DOB is tripping me up. If I could get Excel to treat the truncated/display DOB as text without Excel converting it to its number version of the whole DOB then that would seem to solve the problem... Or maybe there's another approach I haven't thought of yet?
You can use following formula:
=TEXT(A1,"dd.MM.") & "202_"
Change date format "dd.MM" as you need
I'm using an excel document to track my hours at work (this is my 3rd question about it)
I'm trying to figure out how to multiply a time (i.e. 62:05, which is how long I have worked for over 2 weeks), by my hourly rate (11$/hr) and get approximate gross earnings in this format: $667.43
my time format is [hh]:mm and the 11/hr format doesn't do anything other than the total being 29.0000382 something.
Consider this formula:
=A1*24*B1
I've imported an Excel spreadsheet into MATLAB which contains a column of timestamps I would like to extract. However, as Excel stores timestamps as numerical data, the imported cells are now in a non-string format such as 0.4479, 0.4480 etc. Is there a quick way to convert all cells to a HH:MM:SS format?
Yep, datestr can handle this pretty easily.
Given:
numericCellData = {0.4479 0.4480}
Use:
datestr(cell2mat(numericCellData),'HH:MM:SS')
What we are doing:
Use the cell2mat function to convert your cell array to a more typical numeric array. This is what the workhorse datestr expects.
The datestr function is meant to perform this exact type of conversion, from numeric time to a string representation.
Your examples were an interesting specific case, where your values probably represented only time (all values were less than 1; you asked for HH:MM:SS format). For the more general case, of converting numeric date-and-time data from Excel to Matlab, you will usually need to adjust for the date offset used:
Matlab date numbers: Are in units of days, usually double precision, and the 0 value represents January 0, 0000. (Think, new years eve in an era when the Roman empire was the dominant political entity in Europe, as represented by the Gregorian calendar which had not yet been developed.)
Excel date numbers: Are also in units of days. However the number 0 represents January 0, 1900. (Or, new years eve, 1899). This is 693961 in the Matlab system, and sometimes you need to make the adjustment.
Select the Column > Right Click >Format Cells >Number Tab> Select Time under Category > Select the Type and click on Ok