.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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
Maybe you accidentally changed or deleted range names?
Check them out.
 
Upvote 0
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.
 
Upvote 0
Try this experiment and let us know if it worked or not... replace your RGB function with vba.RGB and tell us what happens.
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

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