.interior.color.index = RGB suddenly leading to Run-time error 5 "Invalid procedure, call or argument"

metero75

New Member
Joined
Feb 10, 2021
Messages
8
Platform
  1. MacOS
Hi all, the below macro has been working fine for years and is not working anymore since today. I am on a Mac.

It blocks each time it tries going through the "=RGB" functions such as the following, which returns Run-time error 5 "Invalid procedure, call or argument".
ElseIf Target.Interior.Color = RGB(255, 94, 94)

Can anyone please help?

---

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  
    If Target.Column = Range("Inventory_ID").Column Then
        If Target.Interior.Color = 16777215 Then
            Range(Target, Range("Inventory_Note").Offset(Target.Row - Range("Inventory_ID").Row)).Interior.Color = RGB(255, 94, 94)
            Range("Inventory_Available").Offset(Target.Row - Range("Inventory_ID").Row) = "N"
        ElseIf Target.Interior.Color = RGB(255, 94, 94) Then
            Range(Range("Inventory_ID").Offset(Target.Row - Range("Inventory_ID").Row), Range("Inventory_Note").Offset(Target.Row - Range("Inventory_ID").Row)).Interior.Color = RGB(255, 204, 153)
            Range("Inventory_Available").Offset(Target.Row - Range("Inventory_ID").Row) = "N"
        ElseIf Target.Interior.Color = RGB(255, 204, 153) Then
            Range(Range("Inventory_ID").Offset(Target.Row - Range("Inventory_ID").Row), Range("Inventory_Note").Offset(Target.Row - Range("Inventory_ID").Row)).Interior.Color = xlNone
            Range("Inventory_Available").Offset(Target.Row - Range("Inventory_ID").Row) = "Y"
        'ElseIf Target.Interior.Color = RGB(255, 127, 0) Then
        '    Range(Range("Inventory_ID").Offset(Target.Row - Range("Inventory_ID").Row), Range("Inventory_Note").Offset(Target.Row - Range("Inventory_ID").Row)).Interior.Color = RGB(150, 131, 236)
        'ElseIf Target.Interior.Color = RGB(150, 131, 236) Then
        '    Range(Range("Inventory_ID").Offset(Target.Row - Range("Inventory_ID").Row), Range("Inventory_Note").Offset(Target.Row - Range("Inventory_ID").Row)).Interior.Color = xlNone
        End If
    ElseIf (Target.Column = Range("Inventory_Online").Column Or Target.Column = Range("Inventory_Signed").Column Or Target.Column = Range("Inventory_COA").Column Or Target.Column = Range("Inventory_Framed").Column Or Target.Column = Range("Inventory_Buy_Invoice").Column) And Target.Row > Range("Inventory_Online").Row And Target.Row <= Range("Inventory_ID").End(xlDown).Row Then
        If Target.Value = "Y" Then
            Target.Value = "N"
        ElseIf Target.Value = "N" Then
            Target.Value = "Y"
        Else:
            Target.Value = "N"
        End If
    End If
   
    Cancel = True
   
End Sub

---

Thanks.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
What happens when you type ?RGB(0,00) in the Immediate Window
@mickerison, I am not sure how to verify that through the Immediate Window. However the below works:

Range(Target, Range("Inventory_Note").Offset(Target.Row - Range("Inventory_ID").Row)).Interior.Color = RGB(0, 0, 0)

But I got an error when the numbers are not 255, 94 and 94, which used to work for me.

Thinking about it, I have recently changed computer for a new Macbook Pro 13''. May it be that some RGB colours do not work?
 
Upvote 0
Put “On Error GoTo 0” immediately below Sub and see what line is highlighted.
 
Upvote 0
@kanadaaa thanks but as said the error is here on the first time the macro runs into the RGB function:

Range(Target, Range("Inventory_Note").Offset(Target.Row - Range("Inventory_ID").Row)).Interior.Color = RGB(255, 94, 94)
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,210
Members
453,023
Latest member
alabaz

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