View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JohnUk JohnUk is offline
external usenet poster
 
Posts: 13
Default Range names -VBA

Hi, I need a short code that pick up Range names from a
given number in a cell, and paste elsewhere. The code
below works, but I have in the region of a thousand named
ranges, and as you can imagine, if I kept to the way the
code below is written, it would be extremely long, and
time consuming.

If ActiveCell = "4126" Then
Application.Goto Reference:="A_4126"
Selection.Copy
Sheets("Main Page").Select
Range("B10").Select
ActiveSheet.Paste
Application.Goto Reference:="B_4126"
Selection.Copy
Sheets("Main Page").Select
Range("B29").Select
ActiveSheet.Paste
Range("A1").Select
End If
If ActiveCell = "4128" Then
Application.Goto Reference:="A_4128"
Selection.Copy
Sheets("Main Page").Select
Range("B10").Select
ActiveSheet.Paste
Application.Goto Reference:="B_4128"
Selection.Copy
Sheets("Main Page").Select
Range("B29").Select
ActiveSheet.Paste
Range("A1").Select
End If

And so on, and so on.
Any help greatly appreciated
John