+ Reply to Thread
Results 1 to 14 of 14

.select method with worksheets object ex. Sheets("Sheet1").range.select fail

  1. #1
    Registered User
    Join Date
    02-12-2014
    Location
    Long Beach CA
    MS-Off Ver
    Excel 2007
    Posts
    6

    .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    Hello,

    I am having a problem with this though it is not so much getting done what I want to get done (there are a million ways to do this) but more of something that is blocking my understanding of a bigger concept.

    Please Login or Register  to view this content.
    Why is this? Can someone point me to a good article that explains this. Sorry if this is too basic.

  2. #2
    Registered User
    Join Date
    09-07-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    try this one:

    Sub test01()

    Set test = Worksheets("Sheet1")
    With test
    .Range("A10").Select
    End With

    End Sub

  3. #3
    Registered User
    Join Date
    12-17-2014
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    8

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    I think it's because that worksheet is not the active worksheet.

    Try this. Before test.range("A1").select, activate the worksheet by doing test.activate

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    There is nothing wrong with your code unless you have option explicit as declaration.

    Please Login or Register  to view this content.

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

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    Try this.

    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    02-12-2014
    Location
    Long Beach CA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    Zekaroui: I am using that workaround though I am just confused about the reason why this is failing in the first place.

    AB333: I get the error "Select methos of range class failed" with this code with and without option explicit.

    This works though,

    Please Login or Register  to view this content.
    Thank you all for your replies and attention. Much much appreciated. Sorry if this is VBA 101...

  7. #7
    Registered User
    Join Date
    02-12-2014
    Location
    Long Beach CA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    I just don't understand why the initial code doesn't work...

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    Well, this one works for me too.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-12-2014
    Location
    Long Beach CA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    Is it because I am calling this as a subroutine from a btn_click action. I have the sub in a module and the button click action is called from the sheet code (sorry I don't know exactly what it is called.)

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    It may/may not. Could you please post both codes?

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

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    RobCan

    There's rarely, if ever, any need to select/activate in VBA?

    AB33

    Where are you running the code from and which sheet is active when you run it?

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    Norie,
    There is no active or passive worksheet. I do not see any error on my code.
    It is obviously is the active workbook.

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

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    AB33

    Not sure what you mean, there's always an active sheet.

  14. #14
    Registered User
    Join Date
    02-12-2014
    Location
    Long Beach CA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: .select method with worksheets object ex. Sheets("Sheet1").range.select fail

    Sorry about the delayed response. I am calling the sub routine from a button on another sheet so Sheet1 is not active when I am trying to select the cell.

+ 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] macro to merge worksheets "select method of range class failed"
    By ShoshanaM in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2013, 02:08 PM
  2. VBA error "Method 'Select' of object 'Shape' failed"
    By cvillarl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-04-2012, 08:41 PM
  3. Close WB "Select Method Range Class Fail"
    By konichiwa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-28-2011, 05:09 AM
  4. Select statement producing an error "Select method of worksheet failed"
    By jeskit in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-10-2011, 11:50 AM
  5. Getting "Method 'Range' of Object '_Global Failed" with Range...Select
    By murpat01 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-14-2007, 03:51 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