+ Reply to Thread
Results 1 to 4 of 4

Referencing a range from a different Sheet problem

  1. #1
    Registered User
    Join Date
    02-22-2007
    Posts
    47

    Unhappy Referencing a range from a different Sheet problem

    Hi,

    Here is the the problem:

    1. 2 Worksheets.
    2. A table w/ data on the first one.

    When I activate manually Sheet 1 and run the code it runs smoothly. But when I activate manually Sheet 2 and run the code it gives me an error message - Runtime error '91' - Object variable or With block not set.

    And I really don't understand it 'cause in the code I do activate Sheets(1) before doing anything. So it's a mystery for my why it would not run correctly if launched from any sheets other than Sheets(1).


    Please Login or Register  to view this content.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this
    Please Login or Register  to view this content.
    If you use Sheets(1), the code will activate the first sheet, not necessarily Sheet1. This way of referring to a sheet can cause problems if the position of the sheets is changed. The code I posted will work on Sheet1, which is the Code name of the sheet. Also, it does not need to activate the sheet.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    02-22-2007
    Posts
    47
    Hi RoyUK,

    One question, if I do it w/ WITH structure, will I be able to use Data_Raw_Cell variable (w/ assigned to it Sheets(1) Range) in Functions on the Second (Index) Sheet?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by kyrgyzstanart
    Hi RoyUK,

    One question, if I do it w/ WITH structure, will I be able to use Data_Raw_Cell variable (w/ assigned to it Sheets(1) Range) in Functions on the Second (Index) Sheet?
    I'm not sure what you mean

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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