+ Reply to Thread
Results 1 to 18 of 18

Cell named after Tab name

  1. #1
    Registered User
    Join Date
    03-31-2020
    Location
    Iowa, USA
    MS-Off Ver
    Office 365
    Posts
    18

    Cell named after Tab name

    I'm trying to name in each cell in column I as long as there is data in the row after the tab name by using a macro that I started. For example, The tab name is Smith, Tom and rows 2 through 14 should say Smith, Tom in each cell in column I. This is my first post so I hope I attached the example file correctly.
    Attached Files Attached Files

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Cell named after Tab name

    .
    This is one method :

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-31-2020
    Location
    Iowa, USA
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Cell named after Tab name

    That didn't seem to work. Do I need to change Sheet1 in the formula to populate the cells with the sheet name?

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this ‼


    A VBA single codeline as a beginner starter : Sheet1.Range("I2:I" & Sheet1.[B1].End(xlDown).Row) = Sheet1.Name

    ► Do you like it ? ► ► So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Cell named after Tab name

    Quote Originally Posted by apompo21 View Post
    That didn't seem to work. Do I need to change Sheet1 in the formula to populate the cells with the sheet name?
    No .... so long as the index name of the sheet is SHEET1 ... the macro should work. Do you have more than one sheet this should be executed on ?
    Attached Files Attached Files
    Last edited by Logit; 03-31-2020 at 09:09 PM.

  6. #6
    Registered User
    Join Date
    03-31-2020
    Location
    Iowa, USA
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Cell named after Tab name

    Thanks for doing that. I tried it on a different tab and it doesn't seem to work for other tabs. I'm trying to figure out how to add the attachment.

  7. #7
    Registered User
    Join Date
    03-31-2020
    Location
    Iowa, USA
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Cell named after Tab name

    Yes, I have more than one sheet this should be executed on.

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Cell named after Tab name

    .
    This edited macro will apply the same macro to all sheets in the workbook :

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Logit; 04-02-2020 at 01:41 PM.

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Try this !


    Quote Originally Posted by apompo21 View Post
    Yes, I have more than one sheet this should be executed on.
    Must be indicated in the initial post with an attachment accordingly !

    Anyway, according to post #4, a beginner level VBA demonstration for all worksheets :

    PHP Code: 
    Sub Demo1()
             
    Dim Ws As Worksheet
        
    For Each Ws In ThisWorkbook.Worksheets
                 Ws
    .Range("I2:I" Ws.[B1].End(xlDown).Row) = Ws.Name
        Next
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  10. #10
    Registered User
    Join Date
    03-31-2020
    Location
    Iowa, USA
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Cell named after Tab name

    So, I just want to do one sheet at a time. How do I get it so it only does one sheet at a time? The first one doesn't seem to work. I'd like to be able to post the file that I'm using in here somehow but I can't figure it out. The second code works but it adds it to every single tab. Even tabs that don't need it. I don't know how to change it so it just does the tab that it's currently on.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  11. #11
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Cell named after Tab name

    .
    I realized an error I made in my last post.

    The macro has been changed since then and currently works on all sheets in the workbook.

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Cell named after Tab name

    .
    Update macro with userform :

    Please Login or Register  to view this content.
    See attached example.
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Cell named after Tab name

    Quote Originally Posted by apompo21 View Post
    The second code works but it adds it to every single tab.
    So obviously you just need the post #4 single codeline with the Activesheet statement as worksheet reference …

  14. #14
    Registered User
    Join Date
    03-31-2020
    Location
    Iowa, USA
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Cell named after Tab name

    Is there a way to do this without having to click the box to enter the names?

  15. #15
    Registered User
    Join Date
    03-31-2020
    Location
    Iowa, USA
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Cell named after Tab name

    Post 4 doesn't seem to work for some reason.

  16. #16
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Cell named after Tab name

    .
    You'll need to perform some kinda action to make the macro fire. Don't believe it can get any easier.

    Explain further what you are thinking ...

  17. #17
    Registered User
    Join Date
    03-31-2020
    Location
    Iowa, USA
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Cell named after Tab name

    Thanks everyone. I think I finally got it. I took one of the files someone sent and used portion of what they included.

  18. #18
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Cell named after Tab name

    .
    Glad you have your answer.

    Cheers and stay healthy.

+ 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. [SOLVED] Paste Value from Cell on Dynamic-Named sheet to First empty row on static-named sheet
    By devinddevin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-24-2020, 01:41 PM
  2. Replies: 1
    Last Post: 10-28-2019, 04:14 PM
  3. Listbox displaying named range B but Adding named range A to cell
    By ikkenieikke in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-05-2018, 02:27 PM
  4. VBA to test if a cell is contained in a specific named column in a named table?
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-14-2015, 05:34 PM
  5. [SOLVED] Assign named range to one cell depending on named range in another
    By x65140 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2015, 11:04 AM
  6. [SOLVED] Determining if the value of a cell can be a named range, then assigning named ranges after
    By Romulo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-15-2013, 06:05 PM
  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