Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Using Names in Macros

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Yorkshire
    Posts
    213
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I am writing a macro which selects a varible range of data and then performs a pivot table on it.

    In order to select the range in the pivot table I was going create a name for the range in the macro. I am using varibles to select the first and last cell in the range.

    See below

    Dim startcell
    Dim endcell

    Range("A1").Select
    startcell = ActiveCell.Address
    Selection.End(xlDown).Select
    Selection.End(xlRight).Select
    endcell = ActiveCell.Address

    Range(startcell, endcell).Select
    ActiveWorkbook.Names.Add Name:="Data", RefersToR1C1:= _
    "=DOWNLOAD!R1C1:R5253C7"

    Instead of the "=DOWNLOAD!R1C1:R5253C7" I want to use the startcell, endcell range.

    Can anybody help please.

    Stewart


  2. #2
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    ActiveWorkbook.Names.Add Name:="Data", RefersToR1C1:= _
    selection


    Cheers,

    Nate

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Yorkshire
    Posts
    213
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Nat

    Thanks

    I new it was something simple I was missing.

    Stewart

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •