+ Reply to Thread
Results 1 to 4 of 4

Range selection problem when called from a button.

Hybrid View

  1. #1
    Registered User
    Join Date
    10-10-2014
    Location
    Bristol, England
    MS-Off Ver
    2013
    Posts
    2

    Range selection problem when called from a button.

    I have a button on a worksheet which performs certain functions on the active worksheet.
    It then performs functions on another worksheet within the same workbook.
    It's at this point that I encounter Error 1004, "Select method of Range class failed."

    Sample:
    ThisWorkbook.Sheets("Sheet2").Activate
    Range("A1").Select

    Even if I refer to the range explicitly, the error persists.
    Sample:
    ThisWorkbook.Sheets("Sheet2").Range("A1").Select

    This problem does not occur when run under Kingsoft.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Range selection problem when called from a button.

    Sounds like the sheet name is wrong.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

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

    Re: Range selection problem when called from a button.

    Try this.
    Application.Goto ThisWorkbook.Sheets("Sheet2").Range("A1")
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    10-10-2014
    Location
    Bristol, England
    MS-Off Ver
    2013
    Posts
    2

    Re: Range selection problem when called from a button.

    Thanks for your reply - much appreciated!
    Unfortunately, Application.Goto ThisWorkbook.Sheets("Sheet2").Range("A1") produces the same error.
    Perhaps I need a work around? Button loads worksheet and sets general variable. On loading the page and checking general variable, function executed or ignored?

+ 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. Range selection problem
    By Riverridgefarm in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-10-2014, 06:45 AM
  2. Command button to request user input (selection) of a range of cells
    By KarlGramith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2013, 05:37 PM
  3. Option Button Selection Problem
    By dgratton in forum Excel General
    Replies: 2
    Last Post: 04-03-2008, 04:25 AM
  4. Range Selection problem
    By Coolboy55 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2007, 12:58 PM
  5. The unnamed range selection button
    By MDubbelboer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2006, 10:29 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