Results 1 to 3 of 3

Thread: I have an Excel Range ?

  1. #1

    Thread Starter
    Addicted Member jestes's Avatar
    Join Date
    Jan 2001
    Location
    Dallas
    Posts
    248
    hey gang- I can't seem to make these ranges do what I want them to! Would someone mind taking a look at this macro and slap me with the right answer?

    Code:
    Range("RegisterList").Select
        Selection.Resize(RegRowCount + 1, RegColCount).Select
        ActiveWorkbook.Names("RegisterList").Delete
        NewAddress = "=Register!" & Selection.AddressLocal
        ActiveWorkbook.Names.Add Name:="RegisterList", _
            RefersToLocal:=NewAddress
    this defines the range name, and shows it in the Excel list, but for some reason, when I need to call the name from a different form,(i.e. to load a combobox on a different form) I get an error telling me the name is not valid.

    help?

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Hello,

    I changed your code a little bit and it works fine. Open a new workbook and give this a tried.

    Code:
    Option Explicit
    
    Sub Main()
      Range("RegisterList").Select
      Selection.Resize(3 + 1, 5).Select
      ActiveWorkbook.Names("RegisterList").Delete
      
      Dim NewAddress As String
      NewAddress = "=Register!" & Selection.AddressLocal
      ActiveWorkbook.Names.Add Name:="RegisterList", _
          RefersToLocal:=NewAddress
    End Sub
    Chemically Formulated As:
    Dr. Nitro

  3. #3
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Here is a more simple version of this.

    Code:
    Option Explicit
    
    Sub Main()
      Range("RegisterList").Resize(5, 5).Select
      ActiveWorkbook.Names("RegisterList").Delete
      
      ActiveWorkbook.Names.Add Name:="RegisterList", RefersToLocal:="=" & ActiveSheet.Name & "!" & Selection.AddressLocal
    End Sub
    Chemically Formulated As:
    Dr. Nitro

Posting Permissions

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



Click Here to Expand Forum to Full Width