Relative to Absolute Cell References Macro Help

Felix_Dragonhammer

Board Regular
Joined
Apr 7, 2015
Messages
117
So I found this lovely bit of code off Mr. Excel:

Code:
   Sub Conv_RefType()
       Dim Conv As String
       'Prompt user to change to relative or absolute references
       Conv = Application.InputBox _
           ("Type A to convert to Absolute, R to Relative Reference(s)", _
           "Change Cell Reference Type")
       'If changing relative to absolute references
       If UCase(Conv) = "A" Then
           'Loop through each cell selected
           For Each Mycell In Selection
               If Len(Mycell.Formula) > 0 Then
                   'Stores cell's formula as variable
                   MyFormula = Mycell.Formula
                   'Converts formula to absolute reference style
                   NewFormula = Application.ConvertFormula _
                       (Formula:=MyFormula, _
                       fromReferenceStyle:=xlA1, _
                       toReferenceStyle:=xlA1, _
                       toAbsolute:=xlAbsolute)
                   'Replaces old formula with new absolute formula
                   Mycell.Formula = NewFormula
               End If
           Next
       'If changing absolute to relative references
       ElseIf UCase(Conv) = "R" Then
           'Loop through each cell selected
           For Each Mycell In Selection
               If Len(Mycell.Formula) > 0 Then
                   'Stores cell's formula as variable
                   MyFormula = Mycell.Formula
                   'Converts formula to relative reference style
                   NewFormula = Application.ConvertFormula _
                       (Formula:=MyFormula, _
                       fromReferenceStyle:=xlA1, _
                       toReferenceStyle:=xlA1, _
                       toAbsolute:=xlRelative)
                   'Replaces old formula with new relative formula
                   Mycell.Formula = NewFormula
               End If
           Next
       'Display Error message if choice entered is invalid
       ElseIf UCase(Conv) <> "FALSE" Then
           MyMsg = "Enter A for Absolute, R for Relative Reference(s)"
           MyTitle = "Option Not Valid"
           MyBox = MsgBox(MyMsg, 0, MyTitle)
       End If
   End Sub
The problem is that there are some formulas it doesn't seem to work on.

=SUMIFS('MTD Production Schedule'!$D:$D,'MTD Production Schedule'!$C:$C,'Chart Data'!K$5,'MTD Production Schedule'!$A:$A,'Chart Data'!$B40)

=IF(SUM(I8:I8)>H99,0,IF(SUM(I8:J8)>H99,1,IF(SUM(I8:K8)>H99,2,IF(SUM(I8:L8)>H99,3,IF(SUM(I8:M8)>H99,4,IF(SUM(I8:N8)>H99,5,IF(SUM(I8:O8)>H99,6,IF(SUM(I8:P8)>H99,7,IF(SUM(I8:Q8)>H99,8,IF(SUM(I8:R8)>H99,9,IF(SUM(I8:S8)>H99,10,IF(SUM(I8:T8)>H99,11,IF(SUM(I8:U8)>H99,12,IF(SUM(I8:V8)>H99,13,IF(SUM(I8:W8)>H99,14,IF(SUM(I8:X8)>H99,15,IF(SUM(I8:Y8)>H99,16,17)))))))))))))))))

There is a third one, but it is virtually identical in terms of what it does.

When I try to run the code on those formulas, they return a #VALUE! error, which happens whether I try to make it an absolute or relative reference.

If you could help me with this, I'd appreciate it!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top