VBA code to run macro based on cells updated

MartinBecks

New Member
Joined
Jul 7, 2014
Messages
12
I found this code and changed it to what I need. But I know I left it only half way done. I want to run my macro called Request_Form but only if either cell J2 or T61 is changed. Cells J2 and T61 are dropdown menus. When I change those cells the macro runs correctly however, when I enter information and press enter in any other cell I get the following error.

Run-tine error '1004':
Method 'Range' of object'_Worksheet' failed

Please help me fix this code.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range


For Each cell In Target
If Not Intersect(cell, Range("J2,T61")) Is Nothing Then
Call Request_Form
ElseIf Not Intersect(cell, Range("")) Is Nothing Then

End If
Next cell

End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
See if removing this line fixes things:

ElseIf Not Intersect(cell, Range("")) Is Nothing Then
 
Upvote 0
I found this code and changed it to what I need. But I know I left it only half way done. I want to run my macro called Request_Form but only if either cell J2 or T61 is changed. Cells J2 and T61 are dropdown menus. When I change those cells the macro runs correctly however, when I enter information and press enter in any other cell I get the following error.

Run-tine error '1004':
Method 'Range' of object'_Worksheet' failed

Please help me fix this code.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range


For Each cell In Target
If Not Intersect(cell, Range("J2,T61")) Is Nothing Then
Call Request_Form
ElseIf Not Intersect(cell, Range("")) Is Nothing Then

End If
Next cell

End Sub

JoeMo got it.
 
Last edited:
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