Dear All,
Below Code Copy Multiple Row Ranges and Make It one . It Is working Fine ,but the only problem is that, it takes lot of time when data is huge .
My Sheet Contain a
lmost (2600*5 Row ranges) and below code convert them into 2600 with Column "A"( Which is common Value)
But it takes around 20/30minutes. Please help me in reducing the time .
Public Sub MultipleRowsToOneRow_S6()
Dim lastRow As Long
Dim thisRow As Long
Dim lastCol As Long
Dim nextCol As Long
Application.ScreenUpdating = False
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
thisRow = 2
Do While thisRow <= lastRow
If Cells(thisRow, "A").Value = Cells(thisRow - 1, "A").Value Then
nextCol = Cells(thisRow - 1, Columns.Count).End(xlToLeft).Column + 1
lastCol = Cells(thisRow, Columns.Count).End(xlToLeft).Column
Range(Cells(thisRow, "B"), Cells(thisRow, lastCol)).Copy Destination:=Cells(thisRow - 1, nextCol)
Cells(thisRow, "A").EntireRow.Delete
lastRow = lastRow - 1
Else
thisRow = thisRow + 1
End If
Loop
Application.ScreenUpdating = True
End Sub
Below Code Copy Multiple Row Ranges and Make It one . It Is working Fine ,but the only problem is that, it takes lot of time when data is huge .
My Sheet Contain a
But it takes around 20/30minutes. Please help me in reducing the time .
Public Sub MultipleRowsToOneRow_S6()
Dim lastRow As Long
Dim thisRow As Long
Dim lastCol As Long
Dim nextCol As Long
Application.ScreenUpdating = False
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
thisRow = 2
Do While thisRow <= lastRow
If Cells(thisRow, "A").Value = Cells(thisRow - 1, "A").Value Then
nextCol = Cells(thisRow - 1, Columns.Count).End(xlToLeft).Column + 1
lastCol = Cells(thisRow, Columns.Count).End(xlToLeft).Column
Range(Cells(thisRow, "B"), Cells(thisRow, lastCol)).Copy Destination:=Cells(thisRow - 1, nextCol)
Cells(thisRow, "A").EntireRow.Delete
lastRow = lastRow - 1
Else
thisRow = thisRow + 1
End If
Loop
Application.ScreenUpdating = True
End Sub