Hey,
I'm trying to copy 22 values from 400-something excelfiles and put the values in a specific format in the new sheet. All the values from the first file should end up on row 1 and their respective columns and all the values from file 2 on row 2 and so on. I've tried to base my code off of VBA to copy data from multiple workbooks into master sheet but I can't seem to get it adapted to my use case.
I need multiple if statements within and would like to have the resulting values formated similar to a table starting from a2. This is what I've tested with so far, but it doesn't work and I am unsure how to transpose the values I copy.
I've attached an image of the values I need to copy (starting at h8) and transpose to the other direction.
I hope someone can help - In advance thanks. Please let me know if you need further explanation to help out.
excel
I'm trying to copy 22 values from 400-something excelfiles and put the values in a specific format in the new sheet. All the values from the first file should end up on row 1 and their respective columns and all the values from file 2 on row 2 and so on. I've tried to base my code off of VBA to copy data from multiple workbooks into master sheet but I can't seem to get it adapted to my use case.
I need multiple if statements within and would like to have the resulting values formated similar to a table starting from a2. This is what I've tested with so far, but it doesn't work and I am unsure how to transpose the values I copy.
I've attached an image of the values I need to copy (starting at h8) and transpose to the other direction.
I hope someone can help - In advance thanks. Please let me know if you need further explanation to help out.
VBA Code:
Sub CopyRange()
Application.ScreenUpdating = False
Dim wkbDest As Workbook
Dim wkbSource As Workbook
Set wkbDest = ThisWorkbook
Dim LastRow As Long
Const strPath As String = "H:\Bruger\DLHL\VSP\Lonstat\Source\"
ChDir strPath
strExtension = Dir("*.xlsx*")
Do While strExtension <> ""
Set wkbSource = Workbooks.Open(strPath & strExtension)
With wkbSource
If .Sheets("Ark1").Range(Cells(11, 8)) <> "x" Then
LastRow = .Sheets("Ark1").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Sheets("Ark1").Range("H8:H" & LastRow).Copy wkbDest.Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
.Close savechanges:=False
Else
End If
End With
strExtension = Dir
Loop
Application.ScreenUpdating = True
End Sub
excel