CreativeUsername
Board Regular
- Joined
- Mar 11, 2017
- Messages
- 52
I've been scouring the web and not finding what I need. Also "Excel 2013 Power Programming with VBA" hasn't been able to show me what I need. The code below Is intended to copy data from a range on all tabs except the first one "Skip Me" and paste it into other workbooks. The tabs in "master" correspond to workbooks in the same folder as "Master". So Tabs are : "Alex, Bill, and Sue". Workbooks are "Processor Alex", Processor Bill, Processor Sue. . .Etc. I'm not married to those names in particular. Tabs could include Processor or Processor could be dropped from the file names.
I'm struggling with the part where it finds and opens another workbook. I think i'm really close. I works perfectly if I give it the exact file name but then there is no need for a loop and this is just a test sample. The real project has 12 workbooks and Processors may change so hard coding destinations is cumbersome. The loop works with in the same workbook. So how to make it work, I'm Stumped.
I'm struggling with the part where it finds and opens another workbook. I think i'm really close. I works perfectly if I give it the exact file name but then there is no need for a loop and this is just a test sample. The real project has 12 workbooks and Processors may change so hard coding destinations is cumbersome. The loop works with in the same workbook. So how to make it work, I'm Stumped.
Code:
Sub UpdatebyLoop()
Dim ws As Worksheet
Dim SourceWB As Workbook
Set SourceWB = ThisWorkbook
Application.ScreenUpdating = False
For Each ws In Worksheets
If ws.Name <> "Skip Me" Then
'Debug.Print ws.Name
ws.Activate
ws.Select
Range("A2:M10").Select
Selection.Copy
Workbooks.Open ("C:\Users\Scott\Desktop\VBA Proj\Processor [U][B]" & ws.Name & ".xlsx"[/B][/U]) [COLOR=#ff0000]<----This part gives a "1004" error[/COLOR]
Worksheets(Worksheets.Count).Select 'Selects last worksheet page
'Selects destination looking for first blank cell in "B"
'Set ws = ActiveSheet
For Each Cell In ws.Columns(2).Cells
If IsEmpty(Cell) = True Then Cell.Select: Exit For
Next Cell
ActiveSheet.Paste 'Pastes selection
Application.CutCopyMode = False 'Clears Clipboard for next copy action
End If
Next ws
End Sub [code]