Results 1 to 21 of 21

Changing Formula from absolute to Relative

Threaded View

  1. #1
    Registered User
    Join Date
    09-14-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Changing Formula from absolute to Relative

    Hey,

    I have the code below which builds up an array of data and formulas the applies that array as a range. This is fine except is always comes out as absolute. I then got the code in at the bottom to find ranges of formulas and change them to relative after the data has rendered. This logic works fine on other worksheets but on this worksheet I get the error TypeMismatch when the line RdoRange.Areas(ranges).Formula = _
    Application.ConvertFormula _
    (Formula:=RdoRange.Areas(ranges).Formula, _
    FromReferenceStyle:=xlA1, _
    ToReferenceStyle:=xlA1, ToAbsolute:=xlRelative
    gets hit. Could anyone see what could be going wrong here?

     'Outstanding - Other
             TempArray(Currenti, colSummaryOutstandingOther) = _
                "=SUMIF( Outstanding!" & Range(Cells(intSheetStartRow, colNotInvoicedKey1), Cells(65000, colNotInvoicedKey1)).Address & _
                ", " & Range(Cells(intRow, colSummaryKey1), Cells(intRow, colSummaryKey1)).Address & " & ""/Other""" & _
                ", Outstanding!" & Range(Cells(intSheetStartRow, colInvoicedSplitTotal), Cells(65000, colInvoicedSplitTotal)).Address & ")" & _
                "+SUMIF( PostPay!" & Range(Cells(intSheetStartRow, colNotInvoicedKey1), Cells(65000, colNotInvoicedKey1)).Address & _
                ", " & Range(Cells(intRow, colSummaryKey1), Cells(intRow, colSummaryKey1)).Address & " & ""/Other""" & _
                ", PostPay!" & Range(Cells(intSheetStartRow, colInvoicedSplitTotal), Cells(65000, colInvoicedSplitTotal)).Address & ")"
            
            'Outstanding - Total
             TempArray(Currenti, colSummaryOutstandingTotal) = _
                "=R" & intRow & "C" & colSummaryOutstandingCore & _
                "+R" & intRow & "C" & colSummaryOutstandingCoreSL & _
                "+R" & intRow & "C" & colSummaryOutstanding3Party & _
                "+R" & intRow & "C" & colSummaryOutstanding3PartySL & _
                "+R" & intRow & "C" & colSummaryOutstandingProduct & _
                "+R" & intRow & "C" & colSummaryOutstandingOther
            
            'Total
             TempArray(Currenti, colSummaryTotalCore) = "=R" & intRow & "C" & colSummaryInvoicedCore & "+R" & intRow & "C" & colSummaryOutstandingCore
             TempArray(Currenti, colSummaryTotalCoreSL) = "=R" & intRow & "C" & colSummaryInvoicedCoreSL & "+R" & intRow & "C" & colSummaryOutstandingCoreSL
             TempArray(Currenti, colSummaryTotal3Party) = "=R" & intRow & "C" & colSummaryInvoiced3Party & "+R" & intRow & "C" & colSummaryOutstanding3Party
             TempArray(Currenti, colSummaryTotal3PartySL) = "=R" & intRow & "C" & colSummaryInvoiced3PartySL & "+R" & intRow & "C" & colSummaryOutstanding3PartySL
             TempArray(Currenti, colSummaryTotalProduct) = "=R" & intRow & "C" & colSummaryInvoicedProduct & "+R" & intRow & "C" & colSummaryOutstandingProduct
             TempArray(Currenti, colSummaryTotalOther) = "=R" & intRow & "C" & colSummaryInvoicedOther & "+R" & intRow & "C" & colSummaryOutstandingOther
             TempArray(Currenti, colSummaryTotalTotal) = "=R" & intRow & "C" & colSummaryInvoicedTotal & "+R" & intRow & "C" & colSummaryOutstandingTotal
    
        
    
             Currenti = Currenti + 1
             
             End With
            
            intRow = intRow + 1
        Next
        
       
            Application.ScreenUpdating = False
            Application.Calculate
            Set Person = Nothing
            TheRange.Value = TempArray
             Dim RdoRange As Range
        Dim ranges As Long
    
         Set RdoRange = Selection.SpecialCells(Type:=xlFormulas)
                  For ranges = 1 To RdoRange.Areas.Count
                    RdoRange.Areas(ranges).Formula = _
                    Application.ConvertFormula _
                   (Formula:=RdoRange.Areas(ranges).Formula, _
                    FromReferenceStyle:=xlA1, _
                    ToReferenceStyle:=xlA1, ToAbsolute:=xlRelative)
    
                Next ranges        Application.ScreenUpdating = True
    Last edited by FishGuy; 09-17-2010 at 04:47 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