Hello ,
i need to make the bellow code copy even blank cell (to avoid input data from 2 workbooks in the same row), because the final output is going to be storing the data from each workbook to a single row .
Please help and thanks in advance
i need to make the bellow code copy even blank cell (to avoid input data from 2 workbooks in the same row), because the final output is going to be storing the data from each workbook to a single row .
VBA Code:
Sub Copy_specific_Cells_From_other_workbooks_auto_RF()
Dim FileName$, sPath$
Dim wkbDest As Workbook, wkbSource As Workbook
Dim wsDest As Worksheet, wsSource As Worksheet
Application.ScreenUpdating = False
sPath = "D:\TSSRs\PO11\TSS Reports\WL TSSR\"
'sPath = "C:\Users\user\Documents\HP Laptop\Documents\Documents\Jobs\DIT\IDMB\Stack Overflow\okinawa\"
Set wkbDest = ThisWorkbook
'setting worksheet to improve readability
Set wsDest = wkbDest.Sheets("Master")
FileName = Dir(sPath)
Do While Len(FileName) > 0
'open workbook for read only
Set wkbSource = Workbooks.Open(sPath & FileName)
'setting worksheet to improve readability
Set wsSource = wkbSource.Sheets(2)
wsSource.Range("B2").Copy
wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
wsSource.Range("B4").Copy
wsDest.Cells(wsDest.Rows.Count, "J").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
wsSource.Range("B6").Copy
wsDest.Cells(wsDest.Rows.Count, "K").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
wsSource.Range("B7").Copy
wsDest.Cells(wsDest.Rows.Count, "L").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
'not needed since we're closing the workbook; so it will be done automatically
'Application.CutCopyMode = False
wkbSource.Close SaveChanges:=False
FileName = Dir
Loop
Application.ScreenUpdating = True
End Sub
Please help and thanks in advance