Results 1 to 5 of 5

Macro to Import User defined range to Name Manager

Threaded View

  1. #1
    Registered User
    Join Date
    05-30-2017
    Location
    India
    MS-Off Ver
    MS Office 2016
    Posts
    11

    Macro to Import User defined range to Name Manager

    Hi,

    I'm new to Macro's , i got a macro to Define names and functions from a sheet Range to Name Manager ; the code is as below

    Sub Button2_Click()
    
        Dim wb As Workbook
        Dim ws As Worksheet
        Dim sWsName As String
        Dim sWbName As String
        Set wb = ActiveWorkbook
        Set ws = ActiveSheet
        sWsName = ws.Name
        sWbName = wb.Name
        Dim St1, St2, St3, St4, In5 As Integer
        Dim Inp1, GetString, ExtString As String
        St1 = Range("F3").Value
        St2 = Range("F5").Value
        Inp1 = Range("D3").Value
        St4 = St1
        
        For counter = St1 To St2
            Dim ExtArray() As String
        
            St3 = Inp1 & CStr(St4)
    
            ExtString = Range(St3).Value
            ExtArray() = Split(ExtString, "=")
            wb.Names.Add Name:=ExtArray(0), RefersTo:=ExtArray(1)
            Range("G20").Value = ExtArray(0)
            Range("G21").Value = ExtArray(1)
            St4 = St4 + 1
       
        Next
         
    End Sub
    What i had tried to do is ,
    get the range from cell D3(F3-F5) ie., D3 = K , F3 = 10 , F5 = 20 ,
    then range list is to take K10:K20 strings and delimited by = (by split function)
    which forms name = function ;

    but unfortunately, the function added in the name manager has "" , (like name="function" , where name=function was defined as string in K10-K20 range, which kills the usage the name manager.

    can someone guide to eliminate the "" in this code.
    Last edited by JBeaucaire; 05-30-2017 at 10:31 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Named Range- 'refers to' defined in a cell instead of in the Name Manager
    By MycroftHolmes in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-21-2017, 10:18 AM
  2. [SOLVED] User-defined type not defined on Copy to Clipboard Macro
    By vamosj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2015, 11:31 AM
  3. Copy, paste, replace- user defined range in all the defined sheets
    By aganesan99 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-13-2014, 12:28 PM
  4. Range defined for a name in Name Manager is keep changing
    By maruthi_ravi in forum Excel General
    Replies: 6
    Last Post: 09-29-2013, 12:50 PM
  5. [SOLVED] VBA to import .txt file from user defined drive and folder name - changes each timke
    By heathb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2013, 08:40 AM
  6. Replies: 0
    Last Post: 04-12-2005, 08:06 PM
  7. How to: User Form to assign a user defined range to a macro variab
    By TrevTrav in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2005, 04:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1