How to use an input mask in excel vba? - excel

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

Related

Xls export dispays large numbers as decimals

I am exporting a report in exel format, however, for customer identifiers that are more than 12 digits, the exel displays them as decimals eg 9876520220007 is displayed as 9.88E+12 or as 9.876520220007. This makes it very hard to verify data because the customer identifier is used to check if the records are correct. Any recommendations or links on how i can display the full number will be apreciated. Thanks
My data:
Link to sheet : here
How are you getting the data into excel? Is it via a csv?
In which case you can use the get data from file option which lets you specify the column type as text before excel messes with it.
You can also set the column format to text. This doesn't fix the ones that excel has already interpreted as a long number but any new ones you paste or type in will stay as text.
You can also put an apostrophe before the text in the cell which forces it to be text.
Thats the only one I can suggest up to now as I don't know how you are getting the data into excel.
Select the column and right-click to format cell, and set the decimal place to 0 that should do the trick. but I see you have different types of data in the column you might need to update it individually depending on the case
but I see the

How to stop excel from changing hex number?

I have to enter hex values in a column in excel worksheet.
Now whenever I write the number 01E0, it changes it to 1.00E+00.
How do I stop this from happening?
Excel provides formatting and recognizes your input as a number and tries to display it correctly as a number, containing the Euler number.
In your case, the simplest approach would be to tell Excel to stop doing this, by formatting the column/field/row as text. How to do this is explained here.
Try this if you want the value to be stored as text-
'01E0

Convert from 12 hour time to 24 hour time in excel

I need to convert from 12 hour time to 24 hour time in excel.
I have it on this format:
11/13/2016 7:00:02 AM
I need it to be like this
11.13.2016 07:00:02
How could this be done? I have approximately 1000 cells that need to be converted.
Fully agree with Teylyn - however you may want to change the display and perhaps this is what you actually meant by "conversion". To adapt the display, let's we start with this:
Select the whole range you want to display differently and you can choose from the dropdown "More number format":
Then you can go to "Custom" on the list in the left & select something like this one:
Which gives this:
Or you can use the sample to make up a display of your own (you can edit the format line to yield anything you want).
Edit: if you like the answer, please accept it.
Dates and times are stored as numbers in Excel. How these numbers show in worksheet cells is governed by formatting. If your data contains real date/time values, you don't need to convert anything.
Use formatting to display values in a different time format in the worksheet cells. The date/time will show in the formula bar according to your computer's system settings for date/time display, but that's only in the formula bar.
Use the underlying values unchanged for calculations.

Determining cell format in excel

This seems to be so simple of a request, but I was not able to find an answer. I have a numeric cell and it seems to round numbers. Can I ask excel to tell me formatting settings of a particular cell. For example if the number formatting is fraction up to one digit I would like to know that. It would also be nice to know what the other attributes are; like width, centering, and so on.
You can get some information using the cell function (doc), but it's not as useful as one hopes...
You need to use VBA for more details.

Storing numbers are text Excel 2007

When numbers are stored as text in Excel you see this little guy http://imgur.com/zXdwD
in the upper-left hand corner. when you click on it it gives you the option of converting the text representation of a number to a number upon which math can be done. also, when stored as text numbers appear on the left side of the cell opposed to the right one. I have an array of numbers which are stored as text, but they don't offer that little green thing to convert them to numbers. It may sound trivial but I'm using the Vlookup function to reference a large column of numbers to a code name, but it's not being recognized. And the only thing I can think of is that it's somehow being read differently (the codes are most defintely in the lookup table, and ctrl+f will find them). I want to know if anyone has an idea about what's happening.
Thanks.
The smart tag is a little finicky at times. There's a couple of things you can do.
If you're using code, you can multiply the cells in the range by 1, this will convert them to a number.
Alternatively you can convert the number you're matching to a string and then vlookup. Something similar to:
=VLOOKUP(TEXT(A1,"#"),B1:D10,2,false)
Note TEXT(A1,"#") would round to no decimal places, you may have to adjust the formatting.
The format of some of the cells in the lookup table maybe formatted as text. If there are a lot of them you can create a macro that corrects them. I had the same issue in this SO question although it was the opposite problem.
Another way to correct them would be to copy all the cells in the lookup table in that column and in an adjacent blank column edit>paste special>values>add which makes each of them numeric. Then copy them and paste those back over the originating cells.
A quick trick to convert all numbers formatted as text back to umber format is to copy the data into the "Notepad" application. Then select and copy the data from "Notepad back into your spread sheet and everything will be converted to number format.

Resources