Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88030

Padding a specific number within a string [closed]

$
0
0

I am looking for some help on a formula to pad a specific number within a string.

A typical data set would be like the following:

FD50-U-98-1

FD152-U-2-10

DEM-FD50-U-98-15

DS987-U-XD1498-1

DS987-U-SDD1659-1

within this dataset:

  • for the first three, the third sequence needs to be padded to four digits (I know you can use =TEXT(CELL,"0000") to get that formatting).

  • for the last two, I need the "1498"/"1659" to be padded to 5 digits

The main issue I am having is being able to extract those number to pad it and reinsert it.

Rules:

  • When there's a "DEM", the fourth grouping needs to be modified.
  • when there is a "DS", the third grouping numbers (there will always be letters preceding the third grouping, sometimes it's 1 or 2 or 3 letters) needs to be padded to 5 digits.
  • else, the third grouping needs to be padded to 4 digits

Viewing all articles
Browse latest Browse all 88030

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>