Macro's across Workbooks

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

How would I create a macro that would copy a formula in
one workbook into multiple other workbooks?
 
How would I create a macro that would copy a formula in
one workbook into multiple other workbooks?

You should continue discussions on the same topic in the original thread.

To copy the selected cells in the active worksheet in the active (original)
workbook to all other open workbooks into worksheets with the same name as the
active worksheet containing the source cells and into the same cells within
those worksheets, you could try


Sub foo()
Dim c As Range, wb As Workbook, ws As Worksheet, wsn As String

If Not TypeOf Selection Is Range Then Exit Sub

wsn = Selection.Parent.Name

For Each wb In Workbooks

Set ws = Nothing

If wb.Name <> ActiveWorkbook.Name Then
On Error Resume Next
Set ws = wb.Worksheets(wsn)
Err.Clear
On Error GoTo 0
End If

If Not ws Is Nothing Then

For Each c In Selection.Areas
c.Copy Destination:=ws.Range(c.Address)
Next c

End If

Next wb

End Sub


If you mean closed files, provide details on how those would be selected. Please
respond within *THIS* thread.
 
Back
Top