.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.
 

Some videos you may like

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,971
It sounds like you might have a reference not open.
What happens if you add
VBA Code:
Dim x as OLE_Color
at the beginning of the routine
 

kanadaaa

Active Member
Joined
Dec 29, 2019
Messages
328
Office Version
  1. 365
Platform
  1. Windows
Does anything change if you rewrite this line
VBA Code:
If Target.Interior.Color = 16777215 Then
as
VBA Code:
If Target.Interior.Color = xlWhite Then
or
VBA Code:
If Target.Interior.Color = xlNone Then
 

metero75

New Member
Joined
Feb 10, 2021
Messages
8
Platform
  1. MacOS

ADVERTISEMENT

Thanks but no because that line of code works. It is only the lines with "=RGB(x,x,x)" that do not work.

As I said they have been working for years and I don't know why today they don't work anymore. My file has more rows than before but that is it.
 

kanadaaa

Active Member
Joined
Dec 29, 2019
Messages
328
Office Version
  1. 365
Platform
  1. Windows
Maybe you accidentally changed or deleted range names?
Check them out.
 

metero75

New Member
Joined
Feb 10, 2021
Messages
8
Platform
  1. MacOS

ADVERTISEMENT

No it's not that. I can run the following:
Range(Range("Inventory_ID").Offset(Target.Row - Range("Inventory_ID").Row), Range("Inventory_Note").Offset(Target.Row - Range("Inventory_ID").Row)).Interior.Color.Select

But if I run:
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,94,94) that does not work.

It really looks like it is the RGB function.
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,884
Office Version
  1. 2010
Platform
  1. Windows
Try this experiment and let us know if it worked or not... replace your RGB function with vba.RGB and tell us what happens.
 

metero75

New Member
Joined
Feb 10, 2021
Messages
8
Platform
  1. MacOS
Thanks but still same issue: "Run-time error 5! Invalid procedure, call or argument".
 

Watch MrExcel Video

Forum statistics

Threads
1,127,925
Messages
5,627,667
Members
416,263
Latest member
Doblez

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
Top