zero or not ?

Damntheman30

New Member
Joined
Jan 19, 2020
Messages
2
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Hi,
I need to write function that check: if the number I put in the cell start with 0 it will change the cell attribute to text otherwise the cell attribute will stay general
10x
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You'd be better changing the number format of the cell.

For example "0000" will pad every number so it's 4 digits long (so 1 will become 0001, 10 will be 0010 and so on)
 
Upvote 0
You'd be better changing the number format of the cell.

For example "0000" will pad every number so it's 4 digits long (so 1 will become 0001, 10 will be 0010 and so on)
i didn't explain my self as I want to.
like you wrote I need to change the cell format but I want the excel will do it automaticly. for example:
1234 ---> cell format will be general
01234 ---> cell format will be text
because i need the "0" in the begining
 
Upvote 0
Crossposted zero or not ?

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
I want the excel will do it automaticly. for example:
1234 ---> cell format will be general
01234 ---> cell format will be text
As far as I know, Excel cannot do this. When you edit a cell, no VBA code can run until edit mode has been exited and Conditional Formatting only takes hold after the value has been entered. If the cell is formatted as General, Excel will treat all digits as a number and lop off leading zeros. You have two options... change all the cells in your range of interest to Text before entering data into them (personally, I do not see why you would want a mixture of real numbers and text numbers anyway) or type an apostrophe (') and then follow it with your leading zero number (the apostrophe tells Excel to treat the value as Text even if it is all digits).
 
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,605
Members
449,174
Latest member
ExcelfromGermany

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top