View Single Post
 
Old 08-31-2016, 05:00 PM
p45cal's Avatar
p45cal p45cal is offline Windows 10 Office 2010 32bit
Expert
 
Join Date: Apr 2014
Posts: 947
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

IF the worksheet is like yours with data starting row 1 and IF it's only the'-' and 'f' characters that can be within the page numbers, and IF there are no more than 20 page numbers per row, then try:
Code:
Sub blah()
For rw = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
  Rows(rw).Insert
  With Rows(rw).Resize(, 20)
    .NumberFormat = ""
    .FormulaR1C1 = "=LEFT(R[1]C,MIN(IFERROR(SEARCH(""-"",R[1]C),99),IFERROR(SEARCH(""f"",R[1]C),99))-1)"
    .Resize(2).Sort key1:=Cells(rw, 1), order1:=1, Orientation:=2, DataOption1:=1
  End With
  Rows(rw).Delete
Next rw
End Sub
Reply With Quote