PC Review Forums Newsgroups Microsoft Excel Microsoft Excel Programming relative reference in a macro to define a name

Reply

relative reference in a macro to define a name

 
Thread Tools Rate Thread
Old 27-05-2004, 02:51 AM   #1
Hal Forman
Guest
 
Posts: n/a
Default relative reference in a macro to define a name


I can't seem to get relative referencing to work. I found the toolbar with
Relative Referencing on it, but even when selected, the macro still has
absolute referencing!

Can anyone tell me what the code might look like to:

select the active cell
move end-down
move right 7 columns
define a name for the resulting range

Many thanks!


  Reply With Quote
Old 27-05-2004, 03:16 AM   #2
Bob Kilmer
Guest
 
Posts: n/a
Default Re: relative reference in a macro to define a name

Sub Main()
Dim nms As Names, i As Integer, r As Range

Set r = Range(ActiveCell.End(xlDown), ActiveCell.Offset(0, 7))
Call Names.Add("a_name", "=" & r.Address)

Set nms = ActiveWorkbook.Names
For i = 1 To nms.Count
Debug.Print nms(i).Name
Debug.Print nms(i).RefersToRange.Address
Next

End Sub


"Hal Forman" <halforman@donotspamme.hotmail.com> wrote in message
news:sYatc.23915$0X2.759557@twister.tampabay.rr.com...
> I can't seem to get relative referencing to work. I found the toolbar

with
> Relative Referencing on it, but even when selected, the macro still has
> absolute referencing!
>
> Can anyone tell me what the code might look like to:
>
> select the active cell
> move end-down
> move right 7 columns
> define a name for the resulting range
>
> Many thanks!
>
>



  Reply With Quote
Old 28-05-2004, 08:13 PM   #3
Hal Forman
Guest
 
Posts: n/a
Default Re: relative reference in a macro to define a name

Thanks Bob, that worked, and saved me lots of time. I truly appreciate it.

Hal


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off