Felix_Dragonhammer
Board Regular
- Joined
- Apr 7, 2015
- Messages
- 117
So I found this lovely bit of code off Mr. Excel:
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!
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
=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!