samedi 18 février 2017

a column of excel data to grid format started by each bold term

I have 8000 rows of data in column A of excel, and I am trying to write a code that would scan the rows, and each time there's a bold term, to copy a range that includes that cell and all cells in the subsequent rows until the next bold term, and then paste the whole range into column B, tranposed.

Thanks so much for your help!

Here's the code that I have so far: Sub Sorting()

Application.ScreenUpdating = False
last_row = ActiveSheet.Range("A" & Cells.Rows.Count).End(xlUp).Row
 y = 1

 For i = 1 To LastRow
    If Range("A" & i).Font.Bold = True Then
        Range("A" & i).Copy Range("A" & i + 9)
        Range("B" & y).PasteSpecial Transpose:=True
        y = y + 1
        x = i
    Else
        Range("A" & x).Copy Range("B" & i)
    End If
Next i
Application.ScreenUpdating = True

End Sub

Aucun commentaire:

Enregistrer un commentaire