In my earlier explanation I missed 1 step.
first use this code in each file with data.
Before you run this code make sure:
1) Change the name of the sheet in Data
2) Copy the data in row 2 (the green row)
The result of the code is in sheet output.
Sub CONVERTROWSTOCOL_Oeldere_revisted_new()
Dim rsht1 As Long, rsht2 As Long, i As Long, col As Long, wsTest As Worksheet, mr As Worksheet, ms As Worksheet
'check if sheet "ouput" already exist
Const strSheetName As String = "Output"
Set wsTest = Nothing
On Error Resume Next
Set wsTest = ActiveWorkbook.Worksheets(strSheetName)
On Error GoTo 0
If wsTest Is Nothing Then
Worksheets.Add.Name = strSheetName
End If
'set the data
Set mr = Sheets("DATA") 'this is the name of the source sheet
Set ms = Sheets("Output") 'this is the name of the destiny sheet
col = 5
'End set the data
With ms
.UsedRange.ClearContents
.Range("A1:F1").Value = Array("Offie Code", "Product code", "LYr Avg", "Sales Qty Plan", "Month", "Value")
End With
rsht2 = ms.Range("A" & Rows.Count).End(xlUp).Row
With mr
rsht1 = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 4 To rsht1
Do While .Cells(2, col).Value <> "" 'And .Cells(I, col).Value <> ""
rsht2 = rsht2 + 1
ms.Range("A" & rsht2).Value = .Range("A" & i).Value
ms.Range("B" & rsht2).Value = .Range("B" & i).Value
ms.Range("C" & rsht2).Value = .Range("C" & i).Value
ms.Range("D" & rsht2).Value = .Range("C" & i).Value
ms.Range("E" & rsht2).Value = .Cells(2, col).Value
ms.Range("F" & rsht2).Value = .Cells(i, col).Value
col = col + 1
Loop
col = 5
Next
End With
With ms
' .Range("C2:C" & .Rows.Count).SpecialCells(4).EntireRow.Delete
.Columns("A:Z").EntireColumn.AutoFit
End With
End Sub
After you have done that with all files.
Use the code I gave you earlier (also in this file).
After that a pivot table.
See the attached file.
A) 1files-data1
B) 2020-07-05 (oeldere) abhinavbinkar mergefile
The endresult is in file 2020-07-05 (oeldere) abhinavbinkar mergefile sheet PT Oeldere.
Bookmarks