Run time error '424' - Help!

vu_lan_nhi

New Member
Joined
Apr 6, 2016
Messages
6
Hi

I am relatively new to macro, so excuse my question. I keep receiving error '424' (object required) while trying to run the macro below:
Code:
Private Sub MsgBoxProcessingCredits()


Application.EnableEvents = True
Application.ScreenUpdating = False
If Target.Address = Range("processingdropdown").Address Then
    Application.EnableEvents = False
    If Range("processingdropdown").Value = "Monthly" Then
msgbox ("Select number of months in dropdown list in column C")
Else
msgbox ("Overwrite column C with the flat rate amount for processing credit incentives")
End If
End If
     Application.EnableEvents = True
End Sub
Any help is very much appreciated!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
You are using an object named Target in your If statement but its not initialized anywhere in your Sub.
 
Upvote 0
It seems you are trying to check if selected cell is within a named range. So why not use Selection.Address?

Code:
Private Sub MsgBoxProcessingCredits()

Application.EnableEvents = True
Application.ScreenUpdating = False
      If Selection.Address = Range("processingdropdown").Address Then
             Application.EnableEvents = False
             If Range("processingdropdown").Value = "Monthly" Then
                   msgbox ("Select number of months in dropdown list in column C")
             Else
                   msgbox ("Overwrite column C with the flat rate amount for processing credit incentives")
             End If
End If
     Application.EnableEvents = True
End Sub

Nard
 
Upvote 0
It seems you are trying to check if selected cell is within a named range. So why not use Selection.Address?

Code:
Private Sub MsgBoxProcessingCredits()

Application.EnableEvents = True
Application.ScreenUpdating = False
      If Selection.Address = Range("processingdropdown").Address Then
             Application.EnableEvents = False
             If Range("processingdropdown").Value = "Monthly" Then
                   msgbox ("Select number of months in dropdown list in column C")
             Else
                   msgbox ("Overwrite column C with the flat rate amount for processing credit incentives")
             End If
End If
     Application.EnableEvents = True
End Sub

Nard
Hey thanks, Nard! It works now if I go into macro and hit run, but if I only changing the dropdown selection in my worksheet, the macro does not run when I switch back and forth between different dropdown selection. How should I fix this?
 
Upvote 0
For that you need Target.Address :) However to fire up the macro automatically you need to create an event which will keep a record of changes made to a worksheet.

Just place this in your desired worksheet:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = True
Application.ScreenUpdating = False
      If Target.Address = Range("processingdropdown").Address Then
             Application.EnableEvents = False
             If Range("processingdropdown").Value = "Monthly" Then
                   MsgBox ("Select number of months in dropdown list in column C")
             Else
                   MsgBox ("Overwrite column C with the flat rate amount for processing credit incentives")
             End If
End If
     Application.EnableEvents = True
End Sub

This will see all changes made to a worksheet but Target.Address will tell excel to fire up the macro only when target's address is equal to the address of your dropdown.

Nard
 
Upvote 0
For that you need Target.Address :) However to fire up the macro automatically you need to create an event which will keep a record of changes made to a worksheet.

Just place this in your desired worksheet:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = True
Application.ScreenUpdating = False
      If Target.Address = Range("processingdropdown").Address Then
             Application.EnableEvents = False
             If Range("processingdropdown").Value = "Monthly" Then
                   MsgBox ("Select number of months in dropdown list in column C")
             Else
                   MsgBox ("Overwrite column C with the flat rate amount for processing credit incentives")
             End If
End If
     Application.EnableEvents = True
End Sub

This will see all changes made to a worksheet but Target.Address will tell excel to fire up the macro only when target's address is equal to the address of your dropdown.

Nard

thank you! You're a life saver :)
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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