Run time error 424 - Oblect required.

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I am just trying to clean up a code to make it easier for me and I have moved the following code from the
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal target As Range)

    Dim RowNumSC As Long
RowNumSC = ActiveCell.Row

'COLUMN 16 = P - SHUTTLE CAR
If target.Column = 16 And Range("N" & Selection.Row).Value = Range("N5").Value And _
WorksheetFunction.CountBlank(Range(cells(RowNumSC, 4), cells(RowNumSC, 13))) = 0 Then
MsgBox "1"
Call DisplayUserForm1_CIL(target)
ElseIf target.Column = 16 And Range("N" & Selection.Row).Value <> Range("N6" & Selection.Row).Value And _
Range("O" & Selection.Row).Value <> "" And WorksheetFunction.CountBlank(Range(cells(RowNumSC, 4), cells(RowNumSC, 13))) = 0 Then
MsgBox "2"
Call DisplayUserForm1_CIL(target)
ElseIf target.Column = 16 Then
MsgBox "3"
CIL_Check
End If
End Sub
to a module.

I have deleted the target column from the code but now I am getting the run time error 424 and it highlights this part:
VBA Code:
Call DisplayUserForm1_CIL(target)

I have looked online and tried different things but nothing has worked for me.

Any help would be appreciated.

Thanks

Dan
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
If you've moved the code to a regular module and are now running the code manually then you will need to specify a range in place of Target as that is no longer set automatically.
 
Upvote 0
Hi,

Sorry, I didn't add that I was still calling the code from the selection change event but like this instead:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Column = 57 Then WrapperA
End Sub

and then the code in the standard module:
VBA Code:
 Sub WrapperA()
 Dim RowNumW As Long
RowNumW = ActiveCell.Row
'COLUMN 57 = BE - WRAPPER A
If Range("BC" & Selection.Row).Value = Range("BC5").Value And WorksheetFunction.CountBlank(Range(cells(RowNumW, 37), cells(RowNumW, 54))) = 0 Then
MsgBox "1"
Call DisplayUserForm1_CIL(target)
ElseIf Range("BC" & Selection.Row).Value <> Range("BC6" & Selection.Row).Value And Range("BD" & Selection.Row).Value <> "" And WorksheetFunction.CountBlank(Range(cells(RowNumW, 37), cells(RowNumW, 54))) = 0 Then
MsgBox "2"
Call DisplayUserForm1_CIL(target)
MsgBox "3"

Thanks

Dan
 
Upvote 0
Yes, but you aren't passing Target to the routine you call, so it has no value.
 
Upvote 0
It's not a method that I use, but I believe that you need
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal target As Range)
    If target.Column = 57 Then WrapperA(Target)
End Sub
VBA Code:
Sub WrapperA(Target As Range)
 
Upvote 0
Hi,

With both of your advice, I think I've managed to sort it.

The target was within this sub:
VBA Code:
Sub DisplayUserForm1_CIL(ByVal target As Range)

so I changed this sub to:
VBA Code:
Sub DisplayUserForm1_CIL()

and then set the target within that sub.

Then I deleted the target of the end this line:
VBA Code:
Call DisplayUserForm1_CIL(target)

and now it seems to be working fine.

Thank you both for your help.

Thanks

Dan
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

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