in excel, how to prevent this automatic changing of values like: "12/2013" to "12/1/2013"
if i enter "12/2013" in a cell it is auto changed to "12/1/2013". i donot want this.
Because I want to search for exact "12/2013" later using vba.
You can either use ' as a prefix, i.e. enter '12/2013- or format the column/cell as text beforehand.
Right click on the cell(or cells after selecting them) -> Format Cells -> Number -> Text and re-enter the data of course.
Related
I'm looking to try and do two separate types of validation.
Is it possible to configure validation on a cell to check the first character in that cell and it must be a letter ?
Eg. Anything starting with A-Z case insensitive is fine.
Is is possible to set a cell so it can only contain a number ?
I've got the number check working using =ISNUMBER(J1) that seems to only allow numbers.
I'm trying to check the first character and have tried:
=ISTEXT(LEFT(B10,1)) but that doesn't seem to do what I was hoping..
Thanks
Checking if the whole cell is text is easy with just a simple formula, but if you want to check for only the first letter, then it's more involved.
To ensure that the first character is NOT a number, you can use the custom validation formula
=NOT(ISNUMBER(SUM(LEFT(A1,1),0)))
That will still allow special characters llike $ or & etc. as the first character. If you only want to allow a-z and A-Z as the first letter, then use
=AND(CODE(LEFT(A1,1))>=56,CODE(LEFT(A1,1))<=122)
To allow only numbers, use the built in validation options for Decimal or Whole Number.
Select one or more cells to validate.
Open the Data Validation dialog box.
For this, click the Data Validation button on the Data tab, in the Data Tools group or press
the key sequence Alt > D > L (each key is to be pressed separately).
On the Settings tab of the Data Validation dialog window, select Custom in the Allow box, and enter your data validation formula in
the Formula box.
Click OK.
For text only in a cell build a custom rule with the ISTEXT function, for example:
=ISTEXT(D2)
Custom rule for numbers only in a cell using ISNUMBER.
=ISNUMBER(D2)
Reference: https://www.ablebits.com/office-addins-blog/2017/08/17/use-data-validation-excel-custom-rules-formulas/
we have sort of data in excel like this ---> 34:5:20
excel likes to consider it as time or date.
here is the problem because I know it's not a date and what ever action I want to do with it again
excel thinks it's a date/time value .
how can I stop this behavior ?
(each of the ':' delimited values has a special meaning to me but not date/time)
thanks a lot.
There is one option though, you can use the formula below, to convert the dates back to your format
=CONCAT(" ",TEXT(A2,"[h]:mm:ss"))
I am adding a space using concat function just so that if you ever decide to convert all to value, it will not return back to dates
I found the solution finally .
copy column to notepad.
select another column
change it's format cell to text.
now paste from notepad.
now my data is considered as text and I can separate the values using "column to text" from DATA tab.
thank you all for your valuable time.
Need help regarding excel custom format, there used to be a symbol to format from left to right.
ex.
123456789 -> format 0-0-000 -> would be 12345-6-789
I'm looking for
123456789 -> format [unknown command]0-0-000 -> would be 1-2-3456789
I just can't find them.
Need them in custom format and not in VBA for the sake of frustration can't finding it. Thanks
This should work: #-#-#######
What is important is that the number of hash keys should correspond to the length of your number -> length of, or number of characters in, 123456789 is 9, the same as the number of hash keys above.
You can use conditional formatting to achieve what you need.
Select your data (let's say it's A1-A5)
Open Conditional Formatting > New rule
Select the last type "Use a formula to determine which cells to format"
As a formula type =LEN(A1)=5
Open Format, select Custom and use 0-0-000
Confirm everything
Repeat steps 2-6 as long as you need changing formula to =LEN(A1)=6, =LEN(A1)=7... and format to 0-0-0000, 0-0-00000...
0-0-0000000 is working for 9 digits numbers but for shorter like 12345 it will be 0-0-0012345
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.
In order to save time and simplify my work I need to add the particle "lbs." to every cell I enter a value on.
if I type 123, I need it to automatically read 123lbs
you can custom format the cells:
#.# "lbs"