+ Reply to Thread
Results 1 to 11 of 11

selecting a sheet that matches the name in a cell range

  1. #1
    Registered User
    Join Date
    02-22-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    20

    selecting a sheet that matches the name in a cell range

    Hi,

    I'm having trouble selecting a newly created sheet that matches a name from a range of names in a list. As a new name is entered, it already creates a new sheet for them but then I need it copy another sheet and paste it to the newly created sheet therefore it needs to be selected but as the names are not known, they need to be matched to select the new sheet.

    I need the macro to match the name and select the appropriate sheet. I think I can do it based on a singular cell reference but the cell reference is a variable with every new sheet created.

    Any help is much appreciated!
    Last edited by Muckybox; 04-24-2017 at 10:07 AM.

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

    Re: selecting a sheet that matches the name in a cell range

    How are you creating the new sheet(s)?

    Can you post your current code?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-22-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    20

    Re: selecting a sheet that matches the name in a cell range

    I've been playing around with this but I think I've taken out the other code that I've tried to try and solve my problem. This should be the whole code I'm using.
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: selecting a sheet that matches the name in a cell range

    Re: therefore it needs to be selected

    I don't understand your explanation of what you want to accomplish so I can't really offer anything but you don't need to select a sheet to copy from or paste into.
    As an example, if you are in Sheet1 and you want to copy from Sheet2 into Sheet3, these 3 examples would do that.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: selecting a sheet that matches the name in a cell range

    This is what Muckybox' post #3 code appears to do:
    Please Login or Register  to view this content.
    Last edited by leelnich; 04-23-2017 at 11:56 PM.

  6. #6
    Registered User
    Join Date
    02-22-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    20
    Quote Originally Posted by jolivanes View Post
    Re: therefore it needs to be selected

    I don't understand your explanation of what you want to accomplish so I can't really offer anything but you don't need to select a sheet to copy from or paste into.
    As an example, if you are in Sheet1 and you want to copy from Sheet2 into Sheet3, these 3 examples would do that.
    I think i see your point but i cant define the destination as it changes every time.

    I think theres probably an easier way to do this actually. I have a master sheet that all new sheets i want to add must start with so what im doing is creating a new sheet which sets its name based on a new entry to a database of names and then trying to copy/paste this master sheet to the new players own sheet.

    Im also trying to teach myself all this so im no vba veteran, are these 3 codes doing exactly the same thing?
    Last edited by Muckybox; 04-24-2017 at 10:07 AM.

  7. #7
    Registered User
    Join Date
    02-22-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    20

    Re: selecting a sheet that matches the name in a cell range

    I've solved my issue by changing the way I create the new sheet.

    Instead of creating the sheet, selecting another sheet to copy and then try to match the name to find and select the new page to be able to paste it, I've simply just copied the existing sheet and renamed it that way as part of the code I already had.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: selecting a sheet that matches the name in a cell range

    I would minimize selecting if possible at all.
    This will do the same without the selecting or making visible.
    Run it while in any sheet and see the result.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-22-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    20

    Re: selecting a sheet that matches the name in a cell range

    I tried this and it didn't work. It copied the hidden page, which remained hidden and just changed the name of the next page. I played with not having to make it visible and selecting to start with but was getting errors so decided to just stick with what I've got. Thanks though!

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: selecting a sheet that matches the name in a cell range

    If you would have mentioned all the facts in Post #1, like hidden sheets, things might have been a lot easier.
    Go with whatever works though.
    Good luck

  11. #11
    Registered User
    Join Date
    02-22-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    20

    Re: selecting a sheet that matches the name in a cell range

    True, sorry for the miscommunication.
    I do now have another problem which I believe is the same as my post. Matching a cell reference to a sheet name, is that possible do you know? I put that I though I knew how to do it but I've either forgotten or I was mistaken.

+ 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. Replies: 9
    Last Post: 06-28-2015, 08:07 PM
  2. [SOLVED] VBA Copy Range to another sheet if data matches
    By Metrazal in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-13-2015, 12:23 PM
  3. Pull data from a specific sheet that matches cell value on Input Sheet
    By vaciaravino in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-12-2012, 08:38 PM
  4. Replies: 3
    Last Post: 06-22-2012, 06:40 PM
  5. Error When Selecting Sheet then Selecting Range
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2012, 04:11 AM
  6. Selecting a range on a non-active sheet
    By Newbie_Nick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2010, 10:36 AM
  7. Replies: 1
    Last Post: 10-30-2009, 10:58 AM

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