Error 424 Object Required

nuficek

New Member
Joined
Jul 20, 2016
Messages
37
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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,643
Office Version
  1. 365
Platform
  1. Windows
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.
 

nuficek

New Member
Joined
Jul 20, 2016
Messages
37
It's single cell now but it would be a range in the future, that's why I use evaluate.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,643
Office Version
  1. 365
Platform
  1. Windows
That was just an observation, the cause of the error remains the same regardless of the cell count.
the cause of the error would be that you haven't assigned a range to Target.
 

Darren Bartrup

Well-known Member
Joined
Mar 13, 2006
Messages
1,296
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Where's Target defined?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,729
Office Version
  1. 365
Platform
  1. Windows
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.
 

nuficek

New Member
Joined
Jul 20, 2016
Messages
37

ADVERTISEMENT

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: 1

nuficek

New Member
Joined
Jul 20, 2016
Messages
37
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.
 

nuficek

New Member
Joined
Jul 20, 2016
Messages
37
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: 1

Watch MrExcel Video

Forum statistics

Threads
1,129,905
Messages
5,638,911
Members
417,058
Latest member
BRYCEPIETROWIAK

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
Top