Compile Error Invalid use of property

larrygreg

New Member
Joined
Dec 27, 2011
Messages
46
I am in th process of switching over from a worksheet to vba code.

I am stuck on one are with table lookups.

Code in the workbook is;

=IFERROR(IF(XXX="XXX",VLOOKUP(XXXX,'Directory[EXCEL FILE]SHEET'!$A:$E,5,0))

In my VBA Code, I have;

If Selection.Value = "XXXX" Then
ActiveCell.Offset(0, 3).Select
ActiveCell.FormulaR1C1 "=IFERROR(VLOOKUP(R[0]C[-1], '[File]Sheet'!$A:$E,5,0"""")"
End If
I get a compile error of Invalid use of property.

Any suggestions.

Thanks
 
Perhaps events have been disabled. In the Visual Basic Editor press CTRL + G to open the Immediate window, type

Application.EnableEvents=True

and press Enter. Then try again.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Perhaps events have been disabled. In the Visual Basic Editor press CTRL + G to open the Immediate window, type

Application.EnableEvents=True

and press Enter. Then try again.

Still doesn't work :( . The error has stopped but the trigger doesn't work.
 
Upvote 0
Try this - do you see a message?

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$Q$30" Then
    If Target.Value > 1 Then
        MsgBox "Click OK to sort"
        Call MySort
    End If
End If
End Sub
 
Upvote 0
Try this - do you see a message?

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$Q$30" Then
    If Target.Value > 1 Then
        MsgBox "Click OK to sort"
        Call MySort
    End If
End If
End Sub

Still no luck. I even tried putting the macro (MySort) and the above trigger in the same module (earlier they were in different modules)...though I don't know if it makes a difference. It still doesn't work! :(
 
Upvote 0
The Worksheet_Change code has to go in the sheet's code module. Right click the sheet tab, select View Code and paste in the code.

The MySort macro has to go in a regular module.
 
Upvote 0

Forum statistics

Threads
1,217,143
Messages
6,134,865
Members
449,895
Latest member
rainbow1112

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