Results 1 to 4 of 4

Thread: Refer to sheet by name stored in cell - Amend code

  1. #1
    Board Regular
    Join Date
    Jul 2018
    Location
    Auckland
    Posts
    303
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Refer to sheet by name stored in cell - Amend code

    Hi,

    I have the below coding which works fine but instead of referring to the sheet named "Cordis", I would like it to get the sheet name from cell A12 (which has "Cordis" typed in it).

    Code:
    Private Sub CommandButton1_Click()
    Application.ScreenUpdating = False
    Sheets("Monthly Data").Select
    CleanUp
    Sheets("Cordis").Select
    ClientNarrative
    Sheets("Dashboard").Select
    Application.ScreenUpdating = True
    CommandButton1.Enabled = False
    End Sub
    I have tried

    Code:
    Sheets(Range("A12")).Select
    ClientNarrative
    And

    Code:
    Call Sheets(Range("A12")).Select
    ClientNarrative
    But neither seem to work. Can anyone see how I can get this working please? Thank you

  2. #2
    MrExcel MVP
    Join Date
    May 2009
    Posts
    16,492
    Post Thanks / Like
    Mentioned
    37 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Refer to sheet by name stored in cell - Amend code

    See the modification to your code in bold red font below. Note A12 should contain "Cordis" w/o the quote marks.
    Quote Originally Posted by tlc53 View Post
    Hi,

    I have the below coding which works fine but instead of referring to the sheet named "Cordis", I would like it to get the sheet name from cell A12 (which has "Cordis" typed in it).

    Code:
    Private Sub CommandButton1_Click()
    Application.ScreenUpdating = False
    Sheets("Monthly Data").Select
    CleanUp
    Sheets(Range("A12").Value).Select
    ClientNarrative
    Sheets("Dashboard").Select
    Application.ScreenUpdating = True
    CommandButton1.Enabled = False
    End Sub
    Joe

    When I was a young man I knew everything. Now that I'm older, I realize I know very little, and what I do know, I tend to forget!

  3. #3
    Board Regular
    Join Date
    Jul 2018
    Location
    Auckland
    Posts
    303
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Refer to sheet by name stored in cell - Amend code

    Quote Originally Posted by JoeMo View Post
    See the modification to your code in bold red font below. Note A12 should contain "Cordis" w/o the quote marks.
    Perfect, thank you JoeMo!!

  4. #4
    MrExcel MVP
    Join Date
    May 2009
    Posts
    16,492
    Post Thanks / Like
    Mentioned
    37 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Refer to sheet by name stored in cell - Amend code

    Quote Originally Posted by tlc53 View Post
    Perfect, thank you JoeMo!!
    You are welcome - thanks for the reply.
    Joe

    When I was a young man I knew everything. Now that I'm older, I realize I know very little, and what I do know, I tend to forget!

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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