I am new at creating macros. Only created 5 of them for specific problems.
Could someone help me amend the below macro? I found it on the internet, I amended it to my preferences. But still there is room from improvement. Anyways it works perfectly except for the below.
There would be a lot of files in folder. Each file contains a tab named "PIVOT", where the format are the same, but the amount of data are different.
The range is in the PIVOT tab are from A to AM columns. They start at row 15. And I would only need those lines where the "closed" indication is not written (Status column is in AJ column). I want all of these rows to be copied into a master file under each other. The amount of rows varies greatly - like 0 to 200 depending on the open items.
Secondly, can someone tell me a book, that could be purchased so that I could evolve my knowledge? Thank For your help!
Tibor
Sub Import_to_Master() Dim sFolder As String Dim sFile As String Dim wbD As Workbook, wbS As Workbook
Application.ScreenUpdating = False
Set wbS = ThisWorkbook
sFolder = wbS.Path & "\"
sFile = Dir(sFolder)
Do While sFile <> ""
If sFile <> wbS.Name Then
Set wbD = Workbooks.Open(sFolder & sFile) 'open the file; add condition to
' >>>>>> Adapt this part
wbD.Sheets("PIVOT").Range("A15:AM26").Copy
wbS.Activate
Sheets("Template").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
' >>>>>>
wbD.Close savechanges:=True 'close without saving
End If
sFile = Dir 'next file
Loop
Application.ScreenUpdating = True
End Sub
Range("A" & Rows.Count).End(xlUp)
so you can just modify yourRange("A15:AM26")
using the above code to find the last row in your individual files. – Tim Wilkinson