+ Reply to Thread
Results 1 to 3 of 3

How to reference another worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    03-24-2011
    Location
    belfast
    MS-Off Ver
    Excel 2003
    Posts
    14

    How to reference another worksheet

    Hi All,

    I have some VBA code where I'm trying to compare values from sheet1 and sheet2. In my code for sheet1 I have tried,

    If Worksheets("Sheet2").Cells(2, "B") > 3 Then....
    When I try this I get an error "Subscript out of range". Is it possible what I'm trying to do?

    Thanks in advance.
    Last edited by excel_beg_83; 03-28-2011 at 10:36 AM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,368

    Re: How to reference another worksheet

    Try
    If Worksheets("Sheet2").Cells(2, "B").Value  > 3  Then
    Also - Do you have a Sheet2 in your workbook?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-24-2011
    Location
    belfast
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: How to reference another worksheet

    Hi MarvinP....I'm such an idiot, after reading your post I was looking at the names of my sheets and I had renamed sheet2 but was still referring to it as sheet2. It's working great now.

    Thanks for your help.

+ 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