Error 424 Object Required

nuficek

Board Regular
Joined
Jul 20, 2016
Messages
54
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have this code and I got "Error 424 Object Required". Any idea on the cause? Here's the code:


VBA Code:
Sub AC_idle()

Dim Res As Variant
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Target, Range("N18, Q15:Q28")) Is Nothing Then
      Res = Evaluate("INDEX(N18,MATCH(" & Target.Address & ",J18,0))")
      If Not IsError(Res) Then Target.Offset(, 1) = Res
      End If

End Sub

Any help would be appreciated!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You could simplify the code significantly, there is no need to evaluate match for a single cell, but the cause of the error would be that you haven't assigned a range to Target.
 
Upvote 0
It's single cell now but it would be a range in the future, that's why I use evaluate.
 
Upvote 0
Cross posted Copy row values based on drop down to the column

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
So it's supposed to be like this?

VBA Code:
Sub Aircraft_idle()

Dim Res As Variant
Dim Target As Range
Set Target = Range("N18, Q15:Q28")
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Target, Me.Range("N18, Q15:Q28")) Is Nothing Then
      Res = Evaluate("INDEX(N18,MATCH(" & Target.Address & ",J18,0))")
      If Not IsError(Res) Then Target.Offset(, 1) = Res
      End If

End Sub

I'm quite new in VBA so I thought it's defined in the 5th line.
BTW this is how it should work :
There is a dorp down list in "L18" with days "1d, 2d, 3d ...etc.". This block of code is checking, if I change the this value from the drop down list and calculates it if the appropriate selection is made in the range "Q15:Q28" (so in the column right of this cell).

This is part of another question here Copy row values based on drop down to the column
 

Attachments

  • Flight Idle Days.jpg
    Flight Idle Days.jpg
    75.3 KB · Views: 6
Upvote 0
I would prefer to avoid using VBA as I'm novice in it. But the problem is always that the value can be overwritten/changed by user so function would be deleted. So I'm trying to make my project with functions only but unfortunately sometimes it's inevitable to ask for help to use VBA :cautious: I would wish to have more time to become advance VBA user but to be honest my main profession is totally different. I use this forum as tool to help to myself and I do hope also to many others with searching right answer.
 
Upvote 0
I was trying to looking for change in the "L18" or range of "Q15:Q28" but it only works if I make a change in the range "Q15:Q28". What am I missing?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
Dim Res As Variant
       If Target.CountLarge > 1 Then Exit Sub
       If Not Intersect(Target, Range("L18, Q15:Q28")) Is Nothing Then
          Res = Evaluate("INDEX(N18,MATCH(" & Target.Address & ",J18,0))")
          If Not IsError(Res) Then Target.Offset(, 1) = Res
       End If

End Sub
 

Attachments

  • Flight Idle Days.jpg
    Flight Idle Days.jpg
    75.3 KB · Views: 7
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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