I have been trying to write a macro that does the task of cutting the set of rows and pasting them alongside the columns. I have a sheet named "current sheet" with Columns A to J.Column A consists of Companies name and so on. But every company has more than one Proposal#(Column E), Proposal Text(Column F) so on till Column J. My requirement was to get those second rows cut and pasted to the columns alongside the Column J. I have got it worked with the help of folks in this forum.
Now the output is like what i wanted but with slight variation. I need the same Proposal number (Column E) for each company to be pasted beneath. Example, Company "abc " has its Proposal 2 in Column Q but when I run the above code I get Company "efg" proposal 2 at Column K (i.e. beneath "abc"'s Proposal 1.2). You can look at the "Current output sheet". But I need it to be pasted beneath Column Q. Hope Some one will help as it is very urgent. the desired result is in sheet "desired output". Thanks in advance.
Code:
Sub foo()
Dim lRow As Long, lRowEnd As Long
Application.ScreenUpdating = False
With Sheet1
lRowEnd = .UsedRange.Rows.Count
For lRow = lRowEnd To 2 Step -1
If .Cells(lRow, 1).Value = "" Then
.Range(.Cells(lRow, 1).End(xlToRight), Cells(lRow, Columns.Count).End(xlToLeft)).Copy
.Cells(lRow - 1, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial (xlPasteValues)
.Rows(lRow).EntireRow.Delete
End If
Next lRow
End With
Application.ScreenUpdating = True
End Sub