Results 1 to 4 of 4

code to add two cells together with relational cell names

Threaded View

  1. #1
    Registered User
    Join Date
    10-17-2005
    Posts
    27

    code to add two cells together with relational cell names

    That's probably a terrible thread title, but I'll explain here...

    I'm basically taking over the maintenance of a complex Excel spreadsheet with lots of VB code from a much more experienced programmer who is no longer with our company. This is sort of a side project and not what we do, so there aren't many people around to ask.

    So...here's the piece of code I'm working on - don't laugh. I did this to show you what I'm trying to do:

    Case 25
            Cells(intCurrentRow, 2).Formula = "=B" & intCurrentRow - 2 & " +B" & intCurrentRow - 1
    So, I'm basically telling it that when it creates the worksheet that I'm programming for, I want the forumula in the cell to be (if we are currently on row 24, for example) =B22 + B23

    So, very simple, right? I just don't know how to write this code to back up two and then one row, because the 22 and 23 could be different on different worksheets.

    Let me know if you need more info, and tia!
    Last edited by rylo; 08-14-2008 at 09:27 PM.

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