Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Naming Ranges in VBA (2000)

    why doesnt this work

    Public sub psubnamemyrange(strran1,strran2,strsht,intr)

    ActiveWorkbook.Names.Add Name:=stRran1, RefersToR1C1:="=" & stRsht & "!R" & IntR + 1 & "C2"
    ActiveWorkbook.Names.Add Name:=STrran2, RefersToR1C1:="=" & stRsht & "!R3C2:R" & IntR & "C2"

    end sub

    when this does work

    public sub subnameoneofmyrange
    ActiveWorkbook.Names.Add Name:="NewLineb", RefersToR1C1:="=ccdata!R" & IntR + 1 & "C2"
    ActiveWorkbook.Names.Add Name:="NewListb", RefersToR1C1:="=ccdata!R3C2:R" & IntR & "C2"
    end sub

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Naming Ranges in VBA (2000)

    What do you mean by "doesn't work?" Are you getting an error or is there some other problem?

    I tested it with this:
    <pre>Sub test()
    Call pSubNamemyRange("NewLineB", "NewListB", "ccdata", 1)
    End Sub
    </pre>


    And it creates the same names that would be created by running the 2nd sub having intr = 1.

    Steve

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Naming Ranges in VBA (2000)

    DOPE! realised i was passing the wrong variables and it does work ok after all
    the rollercoasting of programming !

Posting Permissions

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