View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default VB for multiple cell names

Is there a pattern in the names that can be detected?

otherwise

Dim v as Variant, v1 as Variant, i as long
v = Array("Name1", "Name2", "Name3", "ModemStandardRent", "Name4")
v1 = Array("Name1A", "Name2A", "House", "BuildAModemStandardRent", "Yard")

for i = lbound(v) to ubound(v)
range(v(i)).Copy Destination:=Range(v1(i))
Next



--
Regards,
Tom Ogilvy



"Carolyn" wrote in message
...
Hello,

I have two sets (paired) of 29 named cells (58 named cells total). In each
pair, I want to copy the contents from cell and paste it to the other.
Typically I'd think of a loop here and feed in each pair of cell names,
but I
don't know how to do this in Excel VB.

Here's my current code for one pair.

Application.Goto Reference:="ModemStandardRent"
Selection.Copy
Application.Goto Reference:="BuildAModemStandardRent"
ActiveSheet.Paste
Application.CutCopyMode = False

Does anyone know of a way to handle this, other than pasting the above
code
29 times and inserting each pair set of names?

Thank you in advance.

Carolyn