
Originally Posted by
s4driver
Thanks for getting back to me. I did replace the tab in the the macro and there's not a blank row first. The file I'm working with is quite large so I just included a sample section of it. Let me know if you can can get it to work.
Here's another:
Sub s4driver()
Dim lr As Long
Dim x As Long
Dim s As String
s = Left(Range("A2"), 7)
Do Until Range("A2") = s
Range("A1").EntireRow.Insert xlDown
Range("A1").Value = Range("A3").Value
Range("A1").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), TrailingMinusNumbers:=True
x = 1
Do Until ActiveCell.Value = ""
ActiveCell.Offset(, 1).Select
x = x + 1
Loop
Range(Cells(1, 1), Cells(1, x - 1)).Copy
Range("A" & Rows.Count).End(3)(2).PasteSpecial Transpose:=True
lr = Cells(Rows.Count, 1).End(xlUp).Row
Range("B" & Rows.Count).End(3)(2).Resize(x - 1).Value = Range("B3").Value
Range("C" & Rows.Count).End(3)(2).Resize(x - 1).Value = Range("C3").Value
Range("D" & Rows.Count).End(3)(2).Resize(x - 1).Value = Range("D3").Value
Range("A1").EntireRow.Delete xlUp
Range("A2").EntireRow.Delete xlUp
Loop
End Sub
Bookmarks