+ Reply to Thread
Results 1 to 3 of 3

How to access Cell value from specific worksheet in Module of Excel VBA.?

  1. #1
    Registered User
    Join Date
    03-27-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    20

    How to access Cell value from specific worksheet in Module of Excel VBA.?

    Hello,
    I am naive to the Excel VBA.
    How to access value of a cell in Module of VBA ?
    I tried and it worked - Sheet1.Range("A4").value , but i want to access the Worksheet with its name.
    I tried but it did not work - Worksheets("ResultReader").Range("A4").value
    I tried but it did not work - Sheets("ResultReader").Range("A4").value

    Please suggest me some specific way.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: How to access Cell value from specific worksheet in Module of Excel VBA.?

    If your worksheets name is "ResultReader" then the last two should have worked. Try:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-27-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: How to access Cell value from specific worksheet in Module of Excel VBA.?

    When i put a formula of a cell like - "=showSheetName(1)" , the value of the cell becomes like as given below for the perticular line ,

    Public Function showSheetName(rownum As Integer) As String

    'showSheetName = Sheets("ResultReader").Range("D8").Value -- returns #VALUE
    'showSheetName = Sheet3.Range("D8").Value -- Returns proper value of the cell
    'showSheetName = (Sheets("ResultReader").Range("D8").Value) -- returns #VALUE
    'showSheetName = Worksheets("ResultReader").Range("D8").Value -- returns #VALUE

    End Function

    Can you please tell me, is there any mistake i have made in the above written code ?

+ 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