Range names in macros - DA

D

Dean

One of the things I don't like about macros is that, if you insert rows, it
will mess up macros programmed to go to specific locations. As my massive
files evolve, I become paranoid, not to do anything that could move things
around (and I'm not organized enough to keep a log of such cells). This
handcuffs me.

I understand that, if you give a cell(s) a range name, then you can use that
instead and then the macro will adjust if the cell gets moved. Can someone
write me the equivalent of the following code if I name the first cell "Joe"
and the block of cells "Jane"?

Application.Goto Reference:="R16C4"
ActiveCell.FormulaR1C1 = "0"
Selection.Copy
Range("D16:D18").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Thanks!
Dean
 
T

Tom Ogilvy

Dim rng as Range
With Range("Jane")
set rng = .Parent.Range(.Cells,.End(xltoRight))
End With
Range("Joe").copy
rng Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
 
D

Dean

thanks tom

Tom Ogilvy said:
Dim rng as Range
With Range("Jane")
set rng = .Parent.Range(.Cells,.End(xltoRight))
End With
Range("Joe").copy
rng Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
 

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