+ Reply to Thread
Results 1 to 6 of 6

Referencing a cell on another worksheet in VBA

  1. #1
    Registered User
    Join Date
    08-23-2010
    Location
    Redford, MI
    MS-Off Ver
    Excel 2003
    Posts
    6

    Referencing a cell on another worksheet in VBA

    Hello,

    I am trying to do an if statement in VBA. From Sheet3 A25 I want to check if the value of Sheet1 F362 > 0. I would then make Sheet3 A25 equal to some value. When you record a Macro and check the code it does more of a relative location type deal and I want to be specific about which cell. Any help would be greatly appriciated.

    KPT

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

    Re: Referencing a cell on another worksheet in VBA

    Hi KPT,
    Macros record using FormulaR1C1 and you want to change it.
    Change
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    Basically change the FormulaR1C1 to Formula format.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-17-2011
    Location
    GuangDong, China
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Referencing a cell on another worksheet in VBA

    How about trying the code as below....

    IF Sheets("sheet1").Range("F362") > 0 Then Sheets("sheet3").Range("A25") = (your own value)

  4. #4
    Registered User
    Join Date
    11-30-2013
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Referencing a cell on another worksheet in VBA

    You can reference a range on another sheet like this:

    Function ReferenceARangeOnAnotherSheet() As Range
    'I wrote Sheet 5 because it is simply easier to differentiate from the
    'exclamation point than a numeral 1 would have been

    Dim Rng As Range
    Set Rng = Range("=Sheet5!$B$1")
    Set ReferenceARangeOnAnotherSheet = Rng

    End Function

    In the immediate window, try:

    Debug.Print ReferenceARangeOnAnotherSheet.Address

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Referencing a cell on another worksheet in VBA

    dascream

    Welcome to the forum.

    We would like to suggest you to take a look to forum rules and in this case specificaly to rule#3.

    Also i am not able to understand what's the meaning to post a reply in (almost) 3 years old thread!
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

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

    Re: Referencing a cell on another worksheet in VBA

    I was ready to answer that 3 year old post but knew s/he should start a new thread with the question.

+ 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