Results 1 to 4 of 4

How do you find the difference between two cells in a macro?

Threaded View

  1. #1
    Registered User
    Join Date
    05-31-2012
    Location
    Portland
    MS-Off Ver
    Excel 2010
    Posts
    6

    How do you find the difference between two cells in a macro?

    Help please!

    This is a tiny chunk of a couple pages of code... I didn't write it, I'm just trying to edit it according to my boss' specifications so it will run faster. Anyways, so I've defined First Year Premium and First Year Premium Prior below, and the macro works up to that point. I want to define cell E3 (k=3 at this point) as the difference between FYPrem (current YTD) and FYPremP (Previous YTD) so I can find the current quarter to date data. Currently, the data that is being pulled for FYPrem is negative and FYPremP is positive...

    I'm getting run-time error 1004: application-defined or object-defined error. How do I fix this??

    FYPrem = "" & Worksheets(TabNames(3)).Name & "!" & Cells(13 + i, 9).Address
    FYPremP = "" & Worksheets(TabNames(8)).Name & "!" & Cells(k, 5).Address
    Worksheets(TabNames(5)).Range("E" & k) = "=-" & (FYPrem + FYPremP)

    I'm really new to VBA... So if you could explain your answer really well, that would be amazing. I don't really want to just copy/paste whatever solution you find without understanding it.

    THANK YOU.

    ***Edit: I can give more code as a context if that helps, I just need to edit some of it because some of the names in the code are confidential...
    Last edited by jr13; 05-31-2012 at 03:02 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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