AOB
Well-known Member
- Joined
- Dec 15, 2010
- Messages
- 669
- Office Version
- 365
- 2016
- 2013
- Platform
- Windows
I have a function - more accurately, a subroutine - to "cleanse" a value in a table (ListObject) after it has been updated by a user (basically, applies certain restrictions that are too complex to do via native Data Validation)
The sub takes, as argument, a Range, and applies any necessary changes directly to the Value before returning.
The sub is called from a Worksheet_Change event, which handles any/all handling on the sheet by checking which cell has just been changed and performing whatever tasks need to be performed. The cell is identified by a simple Intersect between the EntireRow of the Target range (horizontal) and the DataBodyRange of the ListColumn (vertical)
I'm getting an Error 424 : Object Required when it hits the line where it calls the sub - but when I debug it, all the variables are exactly as expected? Intersect(Target.EntireRow, lcoColumnX.DataBodyRange) evaluates to exactly the cell/range I want to run the sub against, it is showing as an Object/Range in the watch window, it has the correct address, everything.
To clarify - if I put a breakpoint at the line where it (is supposed to) call the sub, and add the watch : TypeName(Intersect(Target.EntireRow, lcoColumnX.DataBodyRange)) - it shows as "Range"? So - before I call the sub, the argument I'm passing is definitely a Range object, and that's the only parameter for the sub - so what "object" is required other than the one I'm passing to the sub, which for all I can see, is present and correct?
The sub takes, as argument, a Range, and applies any necessary changes directly to the Value before returning.
VBA Code:
Private Sub CleanseColumnXEntry(rngColumnX As Range)
....
End Sub
The sub is called from a Worksheet_Change event, which handles any/all handling on the sheet by checking which cell has just been changed and performing whatever tasks need to be performed. The cell is identified by a simple Intersect between the EntireRow of the Target range (horizontal) and the DataBodyRange of the ListColumn (vertical)
VBA Code:
Public lcoColumnX As ListColumn
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
Select Case Target.Column
Case lcoColumnX.Range.Column
CleanseColumnXEntry (Intersect(Target.EntireRow, lcoColumnX.DataBodyRange))
....
End Sub
I'm getting an Error 424 : Object Required when it hits the line where it calls the sub - but when I debug it, all the variables are exactly as expected? Intersect(Target.EntireRow, lcoColumnX.DataBodyRange) evaluates to exactly the cell/range I want to run the sub against, it is showing as an Object/Range in the watch window, it has the correct address, everything.
To clarify - if I put a breakpoint at the line where it (is supposed to) call the sub, and add the watch : TypeName(Intersect(Target.EntireRow, lcoColumnX.DataBodyRange)) - it shows as "Range"? So - before I call the sub, the argument I'm passing is definitely a Range object, and that's the only parameter for the sub - so what "object" is required other than the one I'm passing to the sub, which for all I can see, is present and correct?
Last edited: