Results 1 to 3 of 3

Problem with VBA code written in 2007 and run in 2010

Threaded View

  1. #1
    Registered User
    Join Date
    07-16-2012
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2007
    Posts
    2

    Problem with VBA code written in 2007 and run in 2010

    My office is in the middle of upgrading from office 2007 to 2010. I have not noticed any problems with any of my files except for this one. From what I've researched and talked with people it seems that my code is not complex enough (nor am I very advanced) to have my code effected by the upgrade from VBA6 to VBA7. I am still on 2007, but have access to a virtual version of 2010 .

    I have this report that calculates amount of spend for each project that I (and others) run often from a sample of data we pull out of a larger database. Other code sets up the report and pulls out the data for each project to create a sheet for each project with a summary of spend and total spend. Everything works correctly in 2010 except for the calculation part (the very last part) of this macro where the totals (based on the conditions) are placed in B4, B5 and B6. When I run it in 2010, B4, B5 and B6 all have the equation that B6 should have. It seems like the equations are copied over in the cells because when i run it without B6, the equation in B5 is in the cells B4, B5, B6. I run this macro again for the cells C4, C5, C6 and the same thing happens except the equation for C6 is in C4, C5 and C6. I have tried using relative references and that made no difference.

    Sub calcs1()
    
    For Each rcell In Range("PGRange")
    Dim rcell as Range
    Dim POcnt as Integer
    Dim POrng as Range
    Dim POamt as Range
    Dim POmt as Range
    
    
    Sheets(rcell.Value).Activate
            Range("A14").Select
                POcnt = 0
                    Do
                        POcnt = POcnt + 1
                        ActiveCell.Offset(1, 0).Select
                    Loop Until IsEmpty(ActiveCell)
                If POcnt = 0 Then
                    GoTo SU
                Else
                    Set POrng = Range("A14:A" & POcnt + 13)
                        POrng.Name = "POrng_" & rcell
                    Set POamt = Range("B14:B" & POcnt + 13)
                        POamt.Name = "POamt_" & rcell
                    Set POmt = Range("C14:C" & POcnt + 13)
                        POmt.Name = "POmt_" & rcell
                End If
        Range("B4").FormulaR1C1 = "=SUMIF(POmt_" & rcell & ",""*MBE*"",POamt_" & rcell & ")"
        Range("B5").FormulaR1C1 = "=SUMIF(POmt_" & rcell & ",""*WBE*"",POamt_" & rcell & ")"
        Range("B6").FormulaR1C1 = "=SUMIF(POmt_" & rcell & ","""",POamt_" & rcell & ")"
    
    End Sub
    I'd really appreciate any help!
    Last edited by kmichae; 07-18-2012 at 08:18 AM.

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