View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default copying from multiple worksheets

Hi Krista

See
http://www.rondebruin.nl/copy3.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Krista" wrote in message ...
Any suggestions on how I could consolidate 20 workbooks that all have the
same layout. I need to have 1 master file with all data and have this
updated each week.

"M John" wrote:

The output from this macro is a single sheet containing links to all selected
(and copied) cells from the source/original sheets. As such, the links can
be updated via the "Links..." option at or near the bottom of the "Edit"
menu. So, yes, this macro will allow for updating without having to manually
copy and paste the information each time.

MJohn

"Krista" wrote:

I have 20 workbooks that are used for Forecasting across NA. I need to
consolidate them into one summary. Does this marco update automatically? I
need to pull a summary each week and the field could add more records to
their files each week, will the macro take that into account.

"Bernie Deitrick" wrote:

MJohn,

Select the sheets first, then run the macro below.

HTH,
Bernie
MS Excel MVP


Sub CreateLinkedSummary()
Dim SNames() As String
Dim myAdd As String
Dim myRange As Range
Dim mySS As Worksheet
Dim i As Integer
Dim SCnt As Integer
Dim myCol As Integer

SCnt = ActiveWindow.SelectedSheets.Count

If SCnt = 1 Then
If MsgBox("Are you sure - only one sheet?", vbYesNo) _
= vbYes Then
GoTo ShtOK
Else
MsgBox "Select the sheets and re-run the macro."
Exit Sub
End If
End If

ShtOK:

ReDim SNames(1 To SCnt)

For i = 1 To SCnt
SNames(i) = ActiveWindow.SelectedSheets(i).Name
Next i

Set myRange = Application.InputBox( _
"Select Range to link from", Type:=8)
myAdd = myRange.Address

Set myRange = Application.InputBox( _
"Select sheet and range to link to.", Type:=8)

Set mySS = myRange.Parent
myCol = myRange(1).Column
Worksheets(SNames(1)).Range(myAdd).Copy
mySS.Select
myRange.Select
mySS.Paste Link:=True

For i = 2 To SCnt
Worksheets(SNames(i)).Range(myAdd).Copy
mySS.Cells(mySS.Rows.Count, myCol).End(xlUp)(2).Select
mySS.Paste Link:=True
Next i

myRange.Select
Application.CutCopyMode = False
End Sub



"M John" wrote in message
...
Is there a way to copy data from the same range for all selected worksheets
in a workbook? The preferred order of operations would be: select a range
of cells, select desired worksheets to copy from, select destination
worksheet, and then paste special (links) on this target worksheet. Macro
for this?