I use a 3rd party plugin (SheetJS) to dynamically create a excel file. It has columns of dates such as
2019-07-29 04:12:44 PM
If I format it as a table, the problem is excel does not recognize it as a date column, so I only get "Text Filter" as an option. But I noticed that if I copy the date value, pasted in notepad, and then copy from there, and paste back into excel, and then format as table, it recognizes it as a date column showing "Date Filter".
Is there a quick way to do this right in excel?
Thanks
In your SheetJS script, try to manually set your column width to 17 characters using format:
yyymmdd hh:mm:ss
This will create a 17 character value. This will also tell SheetJS that your column defined is a date column and not plain text.
code Snippet can be found [here][1]:
[1]: https://jsfiddle.net/sheetjs/9xneL9wh/
Related
I have several Macros running at once in a file. The output pastes unique dates from B1:Z1 on the next sheet. The dates right now are pasting as ex. 43619 instead of 6/3/2019. I have been troubleshooting this but everything I have found is a whole column instead of rows. Thanks!
To Excel a Date is a number(the number of days since 1/1/1900). The number is formatted to look like a date.
If you are just pasting the values the format is not following and as such the value is reverted to the number.
To apply the formatting just use:
Worksheet("Sheet1").Range("B1:Z1").NumberFormat = "mm/dd/yyyy"
Changing the sheet name to your desired sheet and the number format to the format desired.
I have a data set with column A containing different date formats, the column format is date:
I would like to have all entries in the format dd-mm-yyyy, and one formula for the whole column.
With format cells, I could not get them into the same format.
I tried TEXT(A3, "dd-mm-yyyy"), but this does not do anything.
DATEVALUE(A3) gives me an error.
Is there a simple solution to this?
Given that Excel cannot parse the date before 01-01-1900 you'd need a proper date and then select your range, and go Data>Text to Columns.
Here, select Delimited and click Next. Deselect all options (usually only Tab is selected) and click Next. Select Date option and choose the format which seems to be DMY in your case.
Then you can use the formula such as:
=TEXT(A3,"dd-mm-yyyy")
I have converted my Cube Pivot table to formulas using OLAP Tools > Convert to formulas.
The column labels are dates in UK format, which is fine. The CUBEMEMBER formula is as such:
=CUBEMEMBER("Name of Cube","[Date].[Display Date].&[27/01/2017]")
This is the issue:
If i copy and paste the date 27/01/2017 in this exact format (For example), and paste it above the cell that has the CUBEMEMBER formula, i can succesfully replace the member_expression part with that cell reference in 2 ways:
One: =CUBEMEMBER("Name of Cube","[Date].[Display Date].&["&B8&"]")
Two: =CUBEMEMBER("Name of Cube",B8)
I do not want to have to copy and paste dates, then link to those cells in order for it to work. I want to be able to link to a cell that already has a date in it. The difference is that its not in the EXACT same format as cubemember. Even if i copy the formats of the date, it does not work.
Any guidance??
Dates are stored as numbers in Excel. The way to get the date as you want it is by using TEXT. With Swedish number formats in Windows the date can be shown as text by using this formula:
=TEXT(A1;"ÅÅÅÅ-MM-dd")
the "ÅÅÅÅ" part should probably be "yyyy" or "YYYY" for UK formats and could of course be "dd/MM/yyyy".
i have two sheets the first one to call a value from the second sheet, in the first sheet i have
=IFERROR(VLOOKUP(B2,'sheet'!B5:'sheet'!I2500,8,FALSE),"")
this works fine for all full text fields
but when i have a date time of
04/26/2013 11:27:00
it converts it to 41390.47708
if i manually edit the cell and put in an apostrophe it is fine but if i try and use a macro or another column to add the apostrophe it changes it to a number and then adds the apostrophe.
is there a way to get the formula to treat the cell as text
When you use a function like VLOOKUP it only retrieves the underlying value from the referenced cell, not the formatting (and display of date and time is achieved by formatting) - can't you just format the cell with the formula in the required format?
Right-click on the cell and choose Format Cells > Number > Custom and type this in the box
mm/dd/yyyy hh:mm:ss
If the formula might retrieve text or a date/time you can still format it that way because the text will be unaffected
I have a file where the date column is in a format I cannot make calculations, so I changed the column to another format where I can subtract dates. As usually happens with excel though, only when I double click an entry it changes to the new format.
Does anyone know how I can force all the cells in column to change to the new format, in order for my script to be able to subtract dates for the whole file?
Here is a really easy work-around:
Insert a blank column.
Change the format of the blank column to the date format that you want.
Copy the column with the dates that won't format.
Right-click on the first cell of the blank, formatted column, select Paste Special, select Paste:Values and Operation:Add. (Because the destination cells are blank, the dates will be unchanged.) Click OK.
The dates will now appear as dates.
Try this in your vbScript
objExcel.Cells(Row, Column).NumberFormat = "#0.00"
If you just want to do this via VBA, you can use something like this:
Range("C1:C100").NumberFormat = Range("B2").NumberFormat
The example above just changes the format for cells C1-C100 to whatever the format is in B2.
Update:
I noticed you said that the format is working fine, but dispalys as #######. This typically happens when the column is not wide enough to show the whole value, so resizing it manually or using something like the belwo should fix your issue:
Columns("C:C").EntireColumn.AutoFit
You may also want to try =Datevalue() in an adjacent column. My experience in these types of situation is that Excel doesn't understand that your entries are dates. They are text, and will not change to date simply on a format change. Alternatively you can try text to columns to do the conversion.