View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default Copy Several named Range in many sheets to a summary sheet

hi frank,
I use 'x' as the object designator to make it generic. the named range is
the object.
in my code i used for each x .....next x.
in your code you use for each dbaceA00....next DBaseE00.
you should have got an error: invalid next control variable reference
variables should be generic. change your code back to x and see if that helps.

regards
FSt1

"Frank Situmorang" wrote:

Hello:

I have tried below, but it stuck in the first row of VBA as follows:
Sub AutoShape1_Click()
'
' AutoShape1_Click Macro
' Macro recorded 5/8/2007 by Frank
'

'
Sub MacCopyRanges()
Dim dbaseA00 As Object
Dim dbaseE00 As Object
For Each dbaseA00 In ActiveWorkbook.Names
Range(dbaseA00).Copy
Sheets("Conso").Select
Range("a65000").End(xlUp).Offset(9, 0).PasteSpecial xlPasteAll
Next dbaseE00
End Sub


"FSt1" wrote:

hi,
try somethink like this...
Sub MacCopyRanges()
Dim x As Object
For Each x In ActiveWorkbook.Names
Range(x).Copy
Sheets("sheet1").Select
Range("a65000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll
Next x
End Sub

you may have to adjust to fit your stuff.

Regards
FSt1

"Frank Situmorang" wrote:

Dear Experts:

I have defined the dynamic range using "offset" to overcome the number of
rows which is variable.

From the summary sheet I have defined the name of the range such as
"dbase1", "dbase2", etc... of each sheet.

My question is how can we copy this name range to be combined to the summary
sheet. the structures( number of columns)of all sheets are all the same.

I have thought of starting copying dbase1 to A9, then using End and xldown.
But could you please explain what macro can we use to handle this task.

Many thanks,

Frank