+ Reply to Thread
Results 1 to 9 of 9

HOW to include ActiveSheet vatiable in formula?

  1. #1
    Registered User
    Join Date
    01-28-2011
    Location
    Riga
    MS-Off Ver
    Excel 2003
    Posts
    7

    Thumbs up HOW to include ActiveSheet vatiable in formula?

    I have set variable for active sheet!

    Set s = ActiveSheet

    I can't get formula work for sheet as a variable

    ???? ActiveCell.FormulaR1C1 = "=s!R[-20]C[1]" ????

    How do i force formula from variable sheet???????
    Last edited by madars; 01-31-2011 at 08:56 AM. Reason: removed repeated ? from title

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: HOW to include ActiveSheet vatiable in formula?????

    You could do so:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    01-28-2011
    Location
    Riga
    MS-Off Ver
    Excel 2003
    Posts
    7

    Unhappy Re: HOW to include ActiveSheet vatiable in formula?????

    This didn't work... I got syntax error!

  4. #4
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: HOW to include ActiveSheet vatiable in formula?????

    This macro runs fine:
    Please Login or Register  to view this content.
    In the above code the important is that you use 's' variable to set a worksheet because if you use variable only for the name you need to use this other code:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  5. #5
    Registered User
    Join Date
    01-28-2011
    Location
    Riga
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: HOW to include ActiveSheet vatiable in formula?????

    It works in separate excel but not in this code... Why?

    Please Login or Register  to view this content.
    Mod. edit: CODE tags when posting VBA please - per Forum Rules
    Last edited by DonkeyOte; 01-31-2011 at 04:12 AM.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: HOW to include ActiveSheet vatiable in formula?????

    Without looking at your code in detail - when posting references to sheets always wise to encase within '

    Please Login or Register  to view this content.
    Please also note my edit to your prior post - any/all VBA should be encased within CODE tags per Forum Rules.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: HOW to include ActiveSheet vatiable in formula?

    On an aside - when posting formulae to the worksheet it's worth being aware of the fact that VBA is US-centric.
    This means the .Formula property assumes US delimiters - if you wish/need to post formulae with delimiters per your own locale use .FormulaLocal property.

  8. #8
    Registered User
    Join Date
    01-28-2011
    Location
    Riga
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: HOW to include ActiveSheet vatiable in formula?????

    Works great! Thanks!

    Quote Originally Posted by DonkeyOte View Post
    Without looking at your code in detail - when posting references to sheets always wise to encase within '

    Please Login or Register  to view this content.
    Please also note my edit to your prior post - any/all VBA should be encased within CODE tags per Forum Rules.

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: HOW to include ActiveSheet vatiable in formula?

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

+ 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