+ Reply to Thread
Results 1 to 13 of 13

Removing Spaces from Defined Names So that INDIRECT Still Works

  1. #1
    Registered User
    Join Date
    07-23-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Unhappy Removing Spaces from Defined Names So that INDIRECT Still Works

    Hey!

    This is my first question for this amazing community and thank you in advance for any help that might come through

    I've got a couple of drop-down lists going, I choose the first list item which then decides which data range appears in the second drop-down list by use of the INDIRECT function.
    I have the Defined Names set up for all of my data ranges but now want the first drop-down list to have more elaborate list item names.

    My issue is that the Defined Names can't have spaces in order for the INDIRECT function to work, the names have to match exactly, however, I don't want there to have to be underscores in the first drop-down list items.
    I want them to appear with spaces so that they look nice and neat but still be able to link to the Defined Names and effect the data range that appears in the second drop-down list using the INDIRECT function.

    Is there a way I can do this?

    Many Thanks!

    - Joey
    Last edited by Jutt369; 08-14-2013 at 01:24 AM. Reason: satisfying my grammar itch

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    Hi and welcome to the forum

    The way I handle this is to use an underscore "_" in the named range to mark where the space needs to be, and then use substitute() to change the underscore to a space
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    07-23-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    Thanks! Really glad I found this forum
    Almost got it working, where would i put the substitute function to have it affect the items in the list drop down?

    I've got two sheets; "Sheet 1" and "Lists"
    I'm getting the items for the first drop down from "=Lists!$B$3:$N$3" but some of the items have underscores i.e. "Floor_Hours".
    Just can't figure out where the SUBSTITUTE function should go to remove the underscores from the items when they appear in the first drop down list haha.. does it need to be added when setting up the data validation?

    Apologies for not being able to explain it very well!

    Many Thanks

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    If I understand what you want, then yes, it goes into the DV window, in the formula you have in there to select the range

  5. #5
    Registered User
    Join Date
    07-23-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    thanks

    I mustn't have something set up correctly because it just evaluates in an error every time i try to set it up.

    If i have multiple ranges that are being used by the INDIRECT function, and those ranges have names with underscores instead of spaces so that they link to the items in the first list, how should everything be set up?

    Example
    Blue_Dye <- data range name in cell B3 on the sheet named "Lists"
    Dye 01
    Dye 02
    Dye 03

    Red_Dye <- data range name in cell D3 on the sheet named "Lists"
    Dye 04
    Dye 05
    Dye 06

    so the first drop-down now shows the two items Blue_Dye and Red_Dye, from the DV of =Lists!$B$3:$D$3, and when i choose one of those the second drop down will allow me to choose from the data range defined as either Blue_Dye or Red_Dye.
    Where should I put the SUBSTITUTE function so that the first drop-down displays the data range names without underscores?

    Cheers!

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    i would suggest you upload a sample work book, (all sensitive data removed), showing what data you are working with, a few examples of what your expected outcome is, and how you arrived at that
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.

  7. #7
    Registered User
    Join Date
    07-23-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Smile Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    Oh!
    Learning how to use the forum at the same time haha, thanks!
    File attached.
    You'll see two sheets in the file, I've set up the defined range names, the drop-down lists and the INDIRECT function.
    The drop-down list in Column B (Example_1 to Example_5) is what I would like to remove the underscores from so that the items in the list in Column B are displayed without underscores (with spaces instead)
    but still work with the relevant data ranges which require the names to match exactly so that they will appear in the Column B list.

    Many Thanks!
    Attached Files Attached Files

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    Your list in B3:F3 already has the underscores in - do a Find & Replace to change those to spaces. Now you will see "Example 1", "Example 2" and so on in the drop-down for cell B5 in the Example sheet. Click on C5, then pull up the data validation dialogue and change the List Source to:

    =INDIRECT(SUBSTITUTE(B5," ","_"))

    So now you can have your list in B5 showing spaces, but your named ranges have underscores.

    Hope this helps.

    Pete

  9. #9
    Registered User
    Join Date
    07-23-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    Genius!
    Thanks so much
    I couldn't get my head around where to put the SUB but now it all makes sense.. seems so obvious once it all falls into place haha
    I was trying to put the SUB in with the Column B DV but now i see that it has to be in with the INDIRECT so that it doesn't create a circular reference and will work!

    Thanks Pete, saved me

  10. #10
    Registered User
    Join Date
    08-03-2016
    Location
    Red Deer, Alberta, Canada
    MS-Off Ver
    2010
    Posts
    3

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    In order to remove the underscores from the defined names I understand how to use this formula (as an example): =INDIRECT(SUBSTITUTE($E11," ","_"))

    Can someone tell me where to put the SUBSTITUTE formula in this string that was designed to allow the use of asterisks in a list but I also want to remove underscores?
    =INDIRECT(VLOOKUP($G2,COM_bLookup,1,0)&"List")

    Thanks so much.

  11. #11
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    swestin,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

  12. #12
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    @swestin,

    The mods are quite strict in applying the Forum Rules (you can read them at the top of the screen), and rule 02 states that you should not hijack someone else's thread - instead, you should start your own thread, and provide a link back to this thread if you think it is relevant.

    I would also suggest that you attach a sample Excel workbook in your new thread. To do this, click on Go Advanced (below the Edit Window) while you are composing a post, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Pete

  13. #13
    Registered User
    Join Date
    08-03-2016
    Location
    Red Deer, Alberta, Canada
    MS-Off Ver
    2010
    Posts
    3

    Re: Removing Spaces from Defined Names So that INDIRECT Still Works

    Thanks guys. Newbie.

+ 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. Sum of indirect sheet names with multiple cells (SUM, INDIRECT,SHEETNAME in cell)
    By a1b2c3d4e5f6g7h8 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-12-2013, 08:42 AM
  2. Replies: 1
    Last Post: 05-14-2012, 10:14 AM
  3. Excel 2007 : removing spaces
    By bjamin_w in forum Excel General
    Replies: 4
    Last Post: 02-19-2010, 09:04 AM
  4. Removing Spaces
    By jdomante in forum Excel General
    Replies: 4
    Last Post: 11-18-2009, 04:32 PM
  5. [SOLVED] Removing Defined Names
    By John M in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2005, 07:06 PM

Tags for this Thread

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