+ Reply to Thread
Results 1 to 8 of 8

How to refer to cell in a different sheet?

Hybrid View

  1. #1
    Registered User
    Join Date
    11-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    81

    How to refer to cell in a different sheet?

    Hi,

    I have two sheets: Sheet1 and Sheet2. There is a macro for Sheet1 which needs to refer to a cell A1 in Sheet2. What is the code for the reference to Sheet2? I tried ...Sheets("Sheet2").Range("A1").Value, but not working.

  2. #2
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: How to refer to cell in a different sheet?

    Hi - A sample code to pull value of sheets 2 into any cell in Sheet1:

    Sub Test()
    Range("A1") = Worksheets("Sheet2").Range("C7")
    End Sub
    Hope you are able to modify this as per your needs.
    If solved kindly remember to mark Thread as solved.
    Click the small star icon at the bottom left of my post if this was useful.

  3. #3
    Registered User
    Join Date
    11-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: How to refer to cell in a different sheet?

    This worked. But if I add something to make it as: Range("A1") = Worksheets("Sheet2").Range("C7").Value

    Then this resulted in an error.


    Quote Originally Posted by kbkumar View Post
    Hi - A sample code to pull value of sheets 2 into any cell in Sheet1:

    Sub Test()
    Range("A1") = Worksheets("Sheet2").Range("C7")
    End Sub
    Hope you are able to modify this as per your needs.

  4. #4
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: How to refer to cell in a different sheet?

    Hi Zjianguk,

    I would not use ".value" in the end at this stage. Would be good if you could upload a sample workbook and share the error you are getting. This will help address your query more efficiently.

    Quote Originally Posted by zjianguk View Post
    This worked. But if I add something to make it as: Range("A1") = Worksheets("Sheet2").Range("C7").Value

    Then this resulted in an error.
    Thanks.

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: How to refer to cell in a different sheet?

    Hello zjianguk,

    I think it may depend on various factors. If Sheets("Sheet2") is in fact Sheet 2, it should work, otherwise it would be better if you could upload a sample WorkBook, with your Code, for us to have a look at.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  6. #6
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: How to refer to cell in a different sheet?

    Complete agree and second Winon's thoughts. Worksheet names while using macros could be tricky at times.

  7. #7
    Registered User
    Join Date
    11-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: How to refer to cell in a different sheet?

    Thanks for your offer to help, Winon

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: How to refer to cell in a different sheet?

    Hello zjianguk,

    You are welcome.

    Mind sharing with us how you got your issue resolved?

+ 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