none
Pulling numbers out of a string and puting the numbers into separate cells. RRS feed

  • Question

  • Hello

    I have a spread sheet that has a big list of part numbers.  I want to pull out the numbers between each deliniator.  Here is the format the part numbers are in:

    ??-##.##?-##.###-##.###-##.###?-?#-??

    The question marks represent letters and the # represent numbers.  Note the numbers are not always 5 places and the decimal might only be the first but could be the second or third place.  Basically I jus want to pull the numbers out between the (-) and put each one in a cell next to it within the same row.

    So if I had this cell ??-##.##?-##.###-##.###-##.###?-?#-?? I would want the 5 cells to the right to show just the numbers between each (-).  Is this possbile?

    Thursday, October 9, 2014 11:44 PM

Answers

  • Try code below.

    Sub test()
    With Sheets(1)
       lastRow = .Range("A" & Rows.Count).End(xlUp).Row
       
       For RowCount = 1 To lastRow
          splitArray = Split(.Range("A" & RowCount), "-")
          For cellOffset = 0 To UBound(splitArray)
             .Range("A" & RowCount).Offset(0, cellOffset + 1) = splitArray(cellOffset)
          Next cellOffset
          
       
       Next RowCount
    
    End With
    
    
    End Sub
    


    jdweng

    Friday, October 10, 2014 4:50 AM