+ Reply to Thread
Results 1 to 11 of 11

Range Select from another worksheet

  1. #1
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    Range Select from another worksheet

    Please Login or Register  to view this content.
    This only works when Sheet1 is selected. If Sheet2 is selected, it returns an error of

    1004
    Select method of Range class failed.

    Sheet1 and Sheet2 are the only sheets in my entire book... When I debug, it goes to the c.Select line...

    I've tried referencing the Sheet1 exactly with Sheets("Sheet1").Range("A:A") and every other possible combination I can think of...
    I do NOT want Sheet1 to need to be selected or even visible necessarily.
    Also the Vals variable is set earlier in the code and returns the correct information...
    Last edited by rybussell; 02-12-2014 at 04:47 PM.

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

    Re: Range Select from another worksheet

    Why do you want to select c?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: Range Select from another worksheet

    I use some ActiveCell.Offset codes later on in the code...

    Let me edit the first post and add the entire code... Give me a moment...

  4. #4
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: Range Select from another worksheet

    Mind you, this isn't all my code.. I'm actually in the process of trying to clean it up... It used to be about 14 times this length.

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

    Re: Range Select from another worksheet

    Can't you use c instead if ActiveCell in the later code?

  6. #6
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: Range Select from another worksheet

    I imagine I could when I get down that far... But I need to figure out why it only works when Sheet1 is selected and not when Sheet2 is selected...

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

    Re: Range Select from another worksheet

    If you mean why doesn't this work,
    Please Login or Register  to view this content.
    then it's because you can't select a range on a sheet unless the sheet is selected.

    The rest of the code should work just fine without Sheet1 being selected.

  8. #8
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: Range Select from another worksheet

    So it's not possible to grab data from a separate sheet in VBA while using With?

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

    Re: Range Select from another worksheet

    Not sure what you mean.

    If you wanted to get the value of a cell/range that you have a reference to all you need is the reference, you don't need With, you don't need to select the sheet the range is on.

    What are you trying to do in the first part of the code you posted?

    It looks like you are trying to find every occurence of Vals in column A of Sheet1, but you don't seem to be doing anything else.

  10. #10
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: Range Select from another worksheet

    It's supposed to search the entire column A on sheet 1 and find the value sent to it by a userform called AccessCredentials. There will be no duplicates in column A.
    It then needs to apply the Range in A where it finds that value from AccessCredentials to a variable.

    From that variable, I should be able to do the Offsets and everything. And like I said, this isn't my code mostly. I'm just trying to make some changes to make it a little more informative. It's a bigger part of a program, but being able to find the value in the column A on Sheet1 and giving a variable a range value is the key to most of my changes.

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

    Re: Range Select from another worksheet

    If there's only one occurence of Vals you don't need a loop or FindNext.

    This should be all you need.
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: Range Select from another worksheet

    Appears to be working... I'll have to check to make sure it didn't affect the other codes in this book. I thank you for the help. Do you have a paypal? I'd like to send you a couple bucks because you have helped me here several times.

+ 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] Select range and then transpose to a new worksheet
    By T15K in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2012, 06:27 AM
  2. How do I select a range on a different worksheet?
    By mhart210 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2011, 03:58 PM
  3. select range in another worksheet
    By nazimscr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2009, 06:43 AM
  4. [SOLVED] IF statement to activate worksheet & select Range
    By MentalDrow in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2006, 03:25 PM
  5. use an input box to select a range and copy to another worksheet
    By Paul in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-03-2006, 11:50 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