Reference to previous sheet VBA question

Hi all,

I am currently using a quick macro in order to reference the previous sheet in excel documents. I’m using it to display trends week by week. (UP DOWN STEADY based on the previous sheet, looks like this =IF(prevsheet(I33)>I33,”#”,IF(prevsheet(I33)<I33, “$”, IF(prevsheet(I33)=I33,”1″))) I am running into a small problem though, in which if i have two excel workbooks open at the same time my trends will change and they will be incorrect, up until i close the second workbook. My macro looks like this:

Function PrevSheet(RCell As Range)

    Dim xIndex As Long

    Application.Volatile

    xIndex = RCell.Worksheet.Index

    If xIndex > 1 Then _

        PrevSheet = Worksheets(xIndex – 1).Range(RCell.Address)

End Function

 

 

So i’m looking on how to lock it only to run on the excel workbook that it’s intended for and not read from another workbook. Should I include something like a filename?

By: usif

18 thoughts on “Reference to previous sheet VBA question

  1. vapormax

    I wanted to make a quick comment to be able to express gratitude to you for the unique tactics you are sharing at this website. My time-consuming internet investigation has at the end of the day been paid with incredibly good content to share with my guests. I would point out that many of us website visitors actually are really lucky to live in a great place with many marvellous individuals with interesting solutions. I feel quite grateful to have encountered your website and look forward to so many more fun minutes reading here. Thanks a lot once more for everything.

  2. mbt

    I’m writing to make you know what a perfect discovery my wife’s daughter experienced reading your web site. She discovered a lot of pieces, most notably how it is like to have an awesome coaching heart to get many more completely master certain advanced topics. You truly surpassed our own expected results. Thank you for coming up with these insightful, dependable, edifying as well as fun thoughts on the topic to Emily.

  3. kyrie 6

    My spouse and i felt quite relieved Louis could finish off his reports via the precious recommendations he received out of the web site. It’s not at all simplistic to just always be giving for free information which often a number of people have been selling. So we do understand we need the blog owner to thank for that. The main explanations you’ve made, the straightforward web site navigation, the friendships your site help to create – it’s everything exceptional, and it’s making our son in addition to the family believe that this situation is interesting, which is certainly pretty pressing. Thanks for the whole thing!

  4. http://urlky.com/

    I don’t know whether it’s just me or if everybody else encountering problems with your website.
    It looks like some of the text within your content
    are running off the screen. Can somebody else please provide feedback and
    let me know if this is happening to them as well? This might be a problem with my internet browser because I’ve had this happen previously.
    Appreciate it

  5. sling tv

    Whoa! This blog looks just like my old one!
    It’s on a totally different subject but it has pretty much the same page layout
    and design. Excellent choice of colors!

  6. sling tv

    My spouse and I stumbled over here from a different web
    address and thought I might check things out.
    I like what I see so i am just following you. Look forward to going over your
    web page repeatedly.

  7. sling tv

    What’s up all, here every one is sharing these experience, so it’s fastidious to
    read this website, and I used to pay a quick visit this website
    every day.

  8. tinyurl.com

    Excellent beat ! I would like to apprentice while you amend your site, how can i
    subscribe for a blog site? The account helped me a appropriate deal.
    I were a little bit familiar of this your broadcast provided vibrant transparent concept

  9. coconut oil

    Heya i’m for the first time here. I came across this board and I find It really useful & it
    helped me out much. I hope to give something back and help others like you
    helped me.

  10. Elanor Lat

    I am often to blogging and i really appreciate your content. The article has really peaks my interest. I am going to bookmark your site and keep checking for new information.

  11. ps4 games

    When I initially commented I clicked the “Notify me when new comments are added”
    checkbox and now each time a comment is added I get several e-mails with the same comment.
    Is there any way you can remove people from that service?
    Bless you!

  12. tinyurl.com

    Hi! Someone in my Myspace group shared this site
    with us so I came to look it over. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers!
    Excellent blog and wonderful design.

Comments are closed.