+ Reply to Thread
Results 1 to 4 of 4

Defind a Named Range based on a cell value

Hybrid View

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2013
    Posts
    75

    Defind a Named Range based on a cell value

    My gut is saying this is impossible, but I figured I could ask since it will make my life easier if it can be achieved


    Say I have a column B10-B20 and the user enters some value into some or all of these cells

    Now is it possible to have a named range that the value would =B10 but also that the name itself of that item would also be dynamic so say someone enters "widget" into B10 the named range would be something like: =CONCATENATE(something,B10)

    Like I said I doubt its feasible but would be really nice if it can be managed.



    Thanks.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Defind a Named Range based on a cell value

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-21-2012
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2013
    Posts
    75

    Re: Defind a Named Range based on a cell value

    Sure, Basically in this example I will have Columns B,C,E COlumns D and F are what I would like the named range to be for the cell to its left So If possible I would have C6 have a name of D6 and E7 having a name that is F7

    I wont know the names people enter if need be I'll make the names be like APIIDuser1 or APICODEuser2 etc but I'm just trying to see if there is a way to get the contents of Columns B into the named range.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-21-2012
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2013
    Posts
    75

    Re: Defind a Named Range based on a cell value

    well I have managed what I want to do after a fashion... I still have a few issues but this is what I've managed so far.

    Option Explicit
    
    Dim OldValue As String                                  ' Variable Needed to Remove old Named Ranges
    
    
    Private Sub Worksheet_Change(ByVal Target As Range)
           
         
        If Target.Address = "$B$11" Then                    ' Overall Range Naming for API Key
         
            If Target.Cells.Count > 1 Then Exit Sub             ' Makes sure there is only 1 cell changing
    
            If Target <> "" Then                                ' This IF Sets Range Name only if Cell is Not Blank
            
                Dim strName As String                               ' Defines Variable
            
                strName = Replace(Target, " ", "_")                 ' Removes Spaces from Target Value
                Range("C11").Name = "EveAPI3_" & strName            ' Sets Range Name
            
            End If                                              ' End Range Nameing
                    
            If OldValue <> "" Then                              ' This If Deletes the Old Range Name, If there was one
                
                Dim oldName As String                               ' More Variables
                Dim oldName2 As String                              ' And More Variables
                
                oldName2 = Replace(OldValue, " ", "_")              ' Removes Spaces from Old Value
                oldName = "EveAPI3_" & OldValue                     ' Sets what the Old Range Name was
                
                On Error Resume Next                                ' Skips over if there is an Error
                ActiveWorkbook.Names(oldName).Delete                ' Deletes the Old Range Name
                
            End If                                              ' End Range Name Deleting
         End If                                             ' Ends API Key Range Naming
    
    End Sub
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        If Selection.Cells.Count > 1 Then                       ' Triggers If Statement if more than 1 cell is selected
            MsgBox "Please select only one cell", vbCritical        ' Error Message
            ActiveCell.Select                                       ' Removes Multiple Selection
        End If                                                  ' End If
        
        If Target.Address = "$B$11" Then                        ' If Statement checking value of Cell before Change
            OldValue = Target                                       ' Sets Variable
        End If                                                  ' End If
    
    End Sub

    I still need to apply this to more than 1 cell, preferably a range of cells or even a full column
    Last edited by Trachr; 08-10-2015 at 11:03 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. named range based on cell text in vba
    By zak.horrocks in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-02-2014, 12:16 PM
  2. named range based on cell text
    By zak.horrocks in forum Excel General
    Replies: 1
    Last Post: 12-02-2014, 12:07 PM
  3. How to sort a named range based on a cell reference
    By numbanine9 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-12-2013, 12:15 PM
  4. VBA Create a named range based on cell value
    By Bonnister in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2013, 03:30 PM
  5. [SOLVED] Cell Value Based on Selection from Named Range
    By Hooty in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2013, 10:39 PM
  6. Replies: 6
    Last Post: 10-14-2009, 03:01 AM
  7. Replies: 1
    Last Post: 06-03-2006, 10:55 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