Hi All,
I am currently using this code provided by @John_w in this thread.
It worked great but I want to change it so the ranges in red (Range("X#:X#").Value) are related to a row heading found in column B instead of a specific row number. I am still wanting to pull data from column Q but instead of there being a row number I want it to relate to a row header round in column B (sometimes the name of the row could be found in B22-24 sometimes it could be B2-4 but the row header would always be Sample 1, Sample 2, Sample 3 and the data I want to pull is always found the column Q).
I hope my explanation is clear. Does anyone have ideas on how to solve this?
Thank you for any suggestions and help in advance.
I am currently using this code provided by @John_w in this thread.
Rich (BB code):
Public Sub Copy_Values_From_Workbooks()
Dim matchWorkbooks As String
Dim destSheet As Worksheet, r As Long
Dim folderPath As String
Dim wbFileName As String
Dim fromWorkbook As Workbook
'Folder path and wildcard workbook files to import cells from
matchWorkbooks = "C:\folder\path\*.xls" 'CHANGE THIS
'Define destination sheet
Set destSheet = ActiveWorkbook.Worksheets("Summary") 'CHANGE THIS
destSheet.Cells.Clear
r = 0
Application.ScreenUpdating = False
folderPath = Left(matchWorkbooks, InStrRev(matchWorkbooks, "\"))
wbFileName = Dir(matchWorkbooks)
While wbFileName <> vbNullString
Set fromWorkbook = Workbooks.Open(folderPath & wbFileName)
With fromWorkbook.Worksheets(1)
destSheet.Range("B8:G8").Offset(r).Value = .Range("E25041'>Q10:V10").Value
destSheet.Range("H8:M8").Offset(r).Value = .Range("E25041'>Q13:V13").Value
destSheet.Range("N8:S8").Offset(r).Value = .Range("Q16:V16").Value
destSheet.Range("A8").Offset(r).Value = .Range("B14").Value
r = r + 1
End With
fromWorkbook.Close savechanges:=False
DoEvents
wbFileName = Dir
Wend
Application.ScreenUpdating = True
MsgBox "Finished"
End Sub
It worked great but I want to change it so the ranges in red (Range("X#:X#").Value) are related to a row heading found in column B instead of a specific row number. I am still wanting to pull data from column Q but instead of there being a row number I want it to relate to a row header round in column B (sometimes the name of the row could be found in B22-24 sometimes it could be B2-4 but the row header would always be Sample 1, Sample 2, Sample 3 and the data I want to pull is always found the column Q).
I hope my explanation is clear. Does anyone have ideas on how to solve this?
Thank you for any suggestions and help in advance.