When generating data/item's code that resembles a scientific number (e.g 124E12) from Progress to Excel, Excel will display it on cell as 1.24E+10. I tried to set excel's cell as text and general before generating but it will still treat it as Scientific. Also tried to use Number and it displayed 124000000000000.
You need to change the display format in Excel.
I'm on a Swedish version of Excel so names below might not be translated the right way.
1) Select the cell/row and right-click. Choose Format Cell in the menu.
2) Choose "Custom format" or similar (in the end of the list).
3) Type ##0,000E+00 and press "OK".
Related
I discovered a trick, but Excel doesn't want to cooperate fully... but maybe there's a workaround...?
I often end up with a date/time on a "tall row" (since other columns are multi-line):
...and I'd like to save vertical space by splitting the date/time onto 2 lines, while keeping it a single numeric value for reasons of sorting, etc:
I realized that this can be accomplished by using a ␊LineFeed character in the custom number format, one of two ways:
Method #1: On a keyboard with a numeric keypad:
Select the cell with the value.
Hit Ctrl+1 to open the Number Formats dialog.
Choose the Custom category and then in the Type: textbox:
Enter the first part of your custom format, ie. yyyy-mm-dd
While holding down Alt enter 0010 on the numeric keypad, and then release Alt
Enter the second part of your custom format, ie. HH:mm am/pm
Hit Enter.
Drag between the row headers to make the row twice as tall:
If Wrap Text is not already on, click it on the Home tab of the ribbon:
👉 Alt + 0010 enters a ␊LineFeed character.
Note: Since Excel doesn't expect this character, the first line you enter in the Type box will disappear as soon as you enter the ␊LineFeed character. There's no way to see it within the dialog (without deleting the ␊LineFeed), but it's still there.
Method #2: On a keyboard without a numeric keypad and/or using VBA:
In the VBA Editor, either within your procedure, or in the Immediate Window (Ctrl + G), you can set the number format for A1 with something like:
Range("A1").NumberFormat="yyyy-mm-dd" & vbLf & "HH:mm am/pm"
...then adjust the row height and make sure Wrap Text is on, via VBA or with steps #5 & 6 above.
👉 vbLf (or Chr(10)) represents a ␊LineFeed character in VBA.
My issue:
This is cool, but it seems that Excel still treats the value like it's one long string on a single line.
This is demonstrated by:
double-clicking between column headers to AutoFit the column:
The column does not "shrink" any further.
double-clicking between row headers to AutoFit the rows:
The row does not "grow to double height".
manually dragging the column to a narrower size.
Excel "thinks" the value doesn't fit:
Any ideas for a workaround?
Perhaps there's a hack to force Excel to display partial values instead of ###### when a formatted numeric value doesn't fit?
Thanks!
You have to shrink-wrap it. See the OP's edit here:
Prevent hash signs (#) showing up in Excel without changing cell format or width
Go to the Alignment tab in the Format Cells dialogue.
Select "Shrink to fit".
Select "Wrap text".
Click "OK".
Excel will still auto-size the column to ~139 pixels, but you can drag the column width to ~71 pixels and still see both lines.
Make sure the Shrink to fit function is ticked
Go to: Right click on cell --> Format Cells --> Alignment --> Shrink to fit
For this example, you can split on two cells instead of doing that. On the first cell, just put the date format without time. On the second cell, do a formula =(the first cell), but put it in time format.
I am looking at a way to shrink this to fit on multiple lines in a cell, but it looks like we don't have the technology to do that automatically in 2020.
READ CAREFULLY THE QUESTION PLEASE, IT MENTIONS EXCEL VBA.
NOT EXCEL
I was given the task of fixing a date input on a VBA form. A textbox should have the user enter the date as MM/DD/YYYY.
I am required to use an input mask, not allowed to do something as validating date after or using a calendar. So far I was able to use the 2 methods mentioned (forcing the format after using ISDATE).
However, it has now been made clear it has to be a mask so keys are filtered on entry, with the mask being visible when entering the date: __/__/____
Where you see underscore, he should only be able to enter numbers and the / are always at those positions
Is there a way to do this? I can only find a tutorial for the mask in Access VBA.
I Googled "Excel input mask" and the 2nd result was: Using an Input Mask Microsoft Excel written by Allen Wyatt...
Using an Input Mask
...You may wonder if there is a way to set up an input mask that will add the colon automatically. The good news is yes, there is. The bad news is no, there isn't. Sound confusing? Let me explain...
You can set up a custom format that will display your time in any format you want. For instance, you could use the following steps:
Select the cells you want to use for time input.
Choose Format from the Cells menu. Excel displays the Format Cells dialog box.
Make sure the Number tab is displayed.
In the Category list, choose Custom.
Replace whatever is in the Type box with #":"00.
Click on OK.
You can now enter your times using just digits. The problem (and this is the bad news) is that the cell doesn't really contain a time. If you enter 230 (for 2:30), it doesn't contain 2:30 as a time—it contains two hundred and thirty. Thus, you can't use the contents of the cell directly in time calculations.
To overcome this, you can use another column to show the entered digits converted into a time. All you need to do is use a formula to do the conversions. For instance, if the time you entered was in cell A3, you could use the following formula in a different cell to do the conversion:
=(INT(A3/100)/24)+((A3 - (INT(A3/100)*100))/1440)
Format the cell that contains the above formula so it displays one of the various time formats, and you are all set.
(Full article and more at the source.)
This post may help you...
Formatting MM/DD/YYYY dates in textbox in VBA
Can Not Get My VLookUp In Excel To Return The Requested Data
I am trying to pull data from another sheet based on data selected from a dropdown on the main sheet.
All the formatting is "General"
=VLOOKUP(F15737,'Location Master'!$A:$J,2,FALSE)
It just keeps returning me #N/A
Try using the Index Match method. It's an alternative to Vlookup which doesn't require data to be sorted and can therefore be of more use.
The typical structure of this method is (the text inside the asterisk will give the ranges specific to your sheet:
=INDEX (**Column from which you want to return a value**, (MATCH(**Lookup Value**, **Column against which you want to lookup**,0))
In this case, if I've understood your workbook structure, the formula should look like this:
=INDEX('Location Master'!$B:$B,(MATCH(F15737,'Location Master'!$A:$A,0)))
This is a common problem with VLOOKUP(). Most likely you have some whitespace (A tab character or some spaces) after one of the values. Click on F15737 and see if there are any spaces at the end of it. Likewise, manually find the value in 'Location Master'!$A and check it for spaces or tabs after the value.
If the whitespace is found in F15737 then you can change your vlookup to be:
=VLOOKUP(TRIM(F15737),'Location Master'!$A:$J,2,FALSE)
If the whitespace is in the range to which you are looking up, then you'll need to trim all of those values, which you can do pretty quickly in a new column with the TRIM() formula.
If this doesn't solve the problem then you might have a number stored as text. Generally excel will tell you if this is the case within the cell with a little green corner indicator. To get Excel to automagically change a column from a "Number stored as Text" to a proper number you can:
Highlight the column
Go to Data>>Text To Columns
Click "Fixed Width"
Click "Finished"
Excel will then format everything automatically (dates to dates, numbers to numbers, text to text, time to time, etc.)
I have a ton of cells that contain dates such as 22/12/2013. This is set automatically as Date format. And if I try to change the cell format to text (Simply because I want it to be text rather than a date so that I can read it later with PHP), the thing changes completely.
Here's how to replicate the error.
Write in a cell 22/10/2013
Change the format to TEXT
The original content gets changed to 41569
I need a way to fix this, because otherwise when I read the date with PHP, it gets convereted to 41569 nonetheless. But if I manage to make it text, it will be alright.
As andy holaday says, using cell formatting to change the format won't actually change existing numbers (dates) to text. You can do that with "text to columns" functionality:
Select column of dates > Data > Text to columns > Next > Next > at step 3, under "column data format" choose "text" > Finish
That converts existing dates, if you have dates to enter which you want to enter as text you can add an apostrophe, as Polly says, or you can simply pre-format the entry column as text format.
It's not an error. Changing the format of a cell does not change the value that is stored in that cell. Excel stores dates as numerical values. What I think you want to do is change the numerical value into text that resembles a date. Try this formula in a new cell somewhere:
= TEXT(A1,"dd/mm/yyyy")
Enter your dates with an apostrophe at the beginning. '22/10/2013 will be interpreted as a text string.
I have a column of content submitted by multiple users, generally pasted into a sheet, from multiple sources. This column has numbers that should always be formatted as text.
In fact, no matter how this is done, there are always a few items that never have the indicator in the left corner warning that these are formatted as text (which we want to see in all cases)
Checking the individual cell, it does show as formatted text, but in reality on an import into a datatable, if the indicator is missing, the datatype is imported as a number.
Clicking after the number and hitting Enter will change the indicator to text.
How can I do that in VBA? I don't want to visit each cell, click on the end of the content and hit enter.Cutting and paste special in no combination reliably fixes these.
What does excel look at, which gets the format issue right with these text format warning indicators, and yet doesn't seem to get it right when you look at the cell format properties?
Excel 2003 but have had the same issue in later versions too.
What worked for me was to check the error indicator, which seemed more reliable than the cell format itself. This looks for anything missing the indicator and forces it to be text.
Unless someone knows something further concerning why this should NOT be done, it solves my issue.
Sub check4textformat()
For Each cell In Range("E2:E15000")
If cell.Errors.Item(xlNumberAsText).Value = False Then cell.Formula = cell.Text
Next
End Sub
You really only need to prepend the text indicator character "'" before every number. Assuming that your values are in the first column, in the first 120 rows, you can do it like this:
For i = 1 To 120
Me.Cells(i, 1).Value = "'" & Me.Cells(i, 1).Value
Next i
If the cell already has a text value, the prepending is ignored. When copying (and when obtaining the value in VBA) the "'" is completely ignored as it only indicates the "type" of the cell contents.
Since your main target is not visiting each cell, I will suggest an easier way than VBA (actually, it's probably the easiest way).
Select the desired column.
Go to Data > Text to Columns.
Select "Delimited" (should be already selected by default) and press "Next".
Uncheck all delimiters and press "Next" (you can also leave the default state of "Tab" as the only delimiter).
Under "Column Data Format", select "Text" and click "Finish".
Done. All the numbers in the column should be stored as text now.