Macro's across Workbooks

R

Ron

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

Harlan Grove

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top