Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ralative range reference

Status
Not open for further replies.
Sep 5, 2003
87
US
I need to be able to copy a cell to a range of cells. I was able to accomplish it by

Selection.Copy
colIndex = ActiveCell.Column
rwIndex = ActiveCell.Row
For rwIndex = 6 To 20
With Worksheets("Sheet1").Cells(rwIndex, colIndex)
Cell(rwIndex, colIndex).Select
ActiveSheet.Paste
End With
Next rwIndex

but I want wondering if there was a way to do it like

Selection.Copy
Range("E7:E16").Select
ActiveSheet.Paste

but using a relative reference rather then the Absolute "E7:E16" reference. I am also considering the R1C1 notation. Any thoughts appreciated.

 
You can specify the destination range immediately after the Copy command (separated by a space). Also, you only need to specify the top-left cell for the paste range. So you can use the Offset function for a relative range:

Selection.Copy Selection.Offset(0, 5)



VBAjedi [swords]
 
Thanks Jedi. I have looked at that one but I need to copy a single cell to a range of cells.

 
Or the one-line version:

Selection.Copy ActiveCell.Range("A1:A10")




VBAjedi [swords]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top