Formula for extracting the first 6 digits of the cell?

SkiliedSin

Board Regular
Joined
May 7, 2018
Messages
51
Office Version
  1. 365
Hello, I am looking for some help on a formula that would give me the first 6 numbers of a cell from left to right. The difficulty is that the cells have varying amounts of letters before the first digit. Thanks!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi,

Would help us help you if you post a few samples of your data.
 
Upvote 0
Whoops, sorry about that.

For example, a few of the cells are xxxxx052012 while others are xxxxxx062012. I am just looking to get the first 6 numbers of the cell.
 
Upvote 0
This is a super messy way to search A1:

Code:
=LEFT(RIGHT(A1,LEN(A1)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))+1),6)

It finds where the first digit(0-9) is hiding, and then stores everything from that point onwards.

Next, it eliminates everything after the first 6 chars.

Note: it only works if your format is like you said (no letters between the numbers and stuff like that)

Edit: Original was via copy/paste, but upon further review this is a cleaner version of the formula:

Code:
=MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),6)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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