New to the site with weak VBA skills. Hoping I can find some assistance with something I have been struggling with for days. I have found many examples that are close, and cant seem to marry them together. I am using Excel 2007. I have a "Summary_Reports" WB, as well as several other workbooks named by employee (eg. "Jim.xls", "bob.xls", etc). Each of the employee workbooks has a named range "caps" sourced from sheet "Tasks". This named range in each employee wb is the same width (number of columns) but can vary in height (number of rows), and some of the rows may be empty. Trying to setup a macro in "Summary_Reports" wb that will open each of the employees wb, copy the named range "caps", and insert/paste only the rows of that range containing data in the first column, to the "Report" sheet in the "Summary_Reports" wb. I assumed the easiest paste method would just be to pick a cell at the top and always insert those rows there, that way each employee would just get inserted above the previous one starting at the same spot. That way no counting or looking for the last populated row on the sheet. I attempted at first to open "Jim.xls" and copy the named range directly from the workbook, but had little success and a lot of trouble with syntax. So I ended up with the code below that pulls the employee sheet into "Summery_Reports" and then copies the named range from itself instead of another wb. Would probably end up deleting those sheets at the end.
What I have started below kinda works, but the data validation I know isn't correct. Correct me if I am wrong but it is only checking the top left cell of "caps" right; if there are contents, it pastes all of "caps", and if that single cell is empty, it pastes nothing. How do I correct the validation to check the first column of every row and also how do I get it to just give me the rows with data?
Also, I know there is a better way to get the "caps" data directly from each of the employee wb, without importing the sheet first. If that can be done easily, I would be very interested in any advice in that regard.
If you are kind enough to help me, please dumb it down as much as possible as I am really interested in actually knowing what the code does and not just copying and pasting. Thank you in advance.
Sub Import_Sheets()
Application.Workbooks.Open ("jim.xls")
Workbooks("jim.xls").Activate
Sheets("Tasks").Copy After:=Workbooks("Summary_Report.xlsm").Sheets("Report")
Application.Workbooks("Jim.xls").Close
'Go to newly copied sheet and name it.
ActiveSheet.Name = "jim"
'Copy the "caps" named range.
With Range("Caps")
If .Cells(1, 1).Value = "" Then
Else
Range("Caps").Select
Selection.Copy
Sheets("Report").Select
Range("B2").Select
Selection.Insert Shift:=xlDown
End If
End With
End Sub