+ Reply to Thread
Results 1 to 2 of 2

Make a Sheet Active from Code

  1. #1
    Registered User
    Join Date
    07-22-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    29

    Make a Sheet Active from Code

    I am trying to write my first piece of code....

    I've added a button to a sheet, and the purpose of the button is to display a view. So the code is:

    Private Sub CommandButton1_Click()
    ThisWorkbook.CustomViews("_Normal").Show
    ThisWorkbook.Worksheets("Share Portfolio").Activate
    End Sub


    Now, line 3 of this code (in red) is erroneous (apparently) - but I guess the intent is clear. When the view "_Normal" is activated, the worksheet displayed is 'whatever', and not what I want. So I'm trying to insert a line of code to display a particular sheet.

    Q1 How do I display a sheet by reference to the sheet name?

    Q2 Is there a way to simply display the sheet onto which the button has been placed?

    thanks

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Make a Sheet Active from Code

    First make sure you have a worksheet named exactly Share Portfolio (e.g. not Shared Portofolio, or added spaces before or after)

    As for naming, many ways to name a call a sheet in vba

    Please Login or Register  to view this content.
    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

+ 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. how to make this vba code active row not cell
    By sspreyer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2013, 07:41 PM
  2. Make this macro select active sheet
    By smugglersblues in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2013, 07:18 PM
  3. [SOLVED] Unhide sheet and make active on cell value
    By Shooter490 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-02-2012, 10:24 PM
  4. [SOLVED] Code to make a sheet active
    By hshayh0rn in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-05-2006, 06:30 PM
  5. [SOLVED] How to make chart embedded in active sheet?
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-09-2005, 03:05 AM

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