View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel[_291_] joel[_291_] is offline
external usenet poster
 
Posts: 1
Default Copy Range and Assign a Defined Name to the Pasted Range


This code is self explanitory

Sub CopyandDefine()

Set SourceRange = Sheets("Sheet1").Range("A1:C3")
Set DestStart = Sheets("Sheet2").Range("B30")

SourceRows = SourceRange.Rows.Count
SourceCols = SourceRange.Columns.Count

Set DestEnd = DestStart.Offset(SourceRows - 1, SourceCols - 1)
Set DestRange = Range(DestStart, DestEnd)

DestString = DestRange.Address(external:=True, ReferenceStyle:=xlR1C1)

ActiveWorkbook.Names.Add Name:="joel", RefersToR1C1:="=" & DestString

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=159845

Microsoft Office Help