Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old January 30th 17, 04:14 AM
Junior Member
 
First recorded activity by ExcelBanter: Jan 2017
Posts: 3
Default Run-time error '424': Object required

The code below allows me highlight one row at a time. I can scroll up and down a sheet using the arrow keys.
Sometimes need to highlight two or more rows by holding shift and clicking multiple rows. The code is only allowing me to highlight one row at a time however I can select multiple rows.

When I try to preform a delete command on multiple rows I have selected I am receiving an this error code after the delete is preformed and I then select another row to highlight:
Run-time error '424': Object required

When I click DEBUG it highlights this row in the code:
For Each Dn In rng


Option Explicit
Dim rng As Range, ray
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Dn As Range, c As Long, col As Long
col = 100
If Not rng Is Nothing Then
c = 0
For Each Dn In rng
c = c + 1
Dn.Interior.ColorIndex = ray(c, 1)
Next Dn
End If
c = 0
Set rng = Cells(Target.Row, 1).Resize(, col)
ReDim ray(1 To rng.Count, 1 To 2)
For Each Dn In rng
c = c + 1
ray(c, 1) = Dn.Interior.ColorIndex
Next Dn
Cells(Target.Row, 1).Resize(, col).Interior.ColorIndex = 6
End Sub

  #2   Report Post  
Old January 30th 17, 11:00 AM posted to microsoft.public.excel.misc
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2015
Posts: 1,182
Default Run-time error '424': Object required

When I click DEBUG it highlights this row in the code:
For Each Dn In rng


In the case of the 1st occurance of this line, you have not 'Set' the
variable "rng" to ref a range!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
  #3   Report Post  
Old January 30th 17, 06:38 PM
Junior Member
 
First recorded activity by ExcelBanter: Jan 2017
Posts: 3
Default

I don't know Garry. Where would I add the range? This isn't my code. I am just using it to help me navigate my excel page. I am clueless. Any help in elaborating would be greatly appreciated.
  #4   Report Post  
Old January 30th 17, 09:28 PM posted to microsoft.public.excel.misc
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2015
Posts: 1,182
Default Run-time error '424': Object required

I don't know Garry. Where would I add the range? This isn't my code.
I am just using it to help me navigate my excel page. I am clueless.
Any help in elaborating would be greatly appreciated.


For starters.., your code is in a sheet event and so it runs every time
you select a new cell *whether you want it to or not*! Delete all the
code and put the following in a standard module...


Option Explicit


Sub HiLiteRows() 'Ctrl+Shift+H
' Shades entire rows of a selection of cells;
' Selection can be multiple areas.

Dim lColor&, vRow

lColor = 6 'Yellow
For Each vRow In Selection.Rows
vRow.EntireRow.Interior.ColorIndex = lColor
Next 'vRow

End Sub 'HiLiteRows

...and assign a keyboard shortcut to it so you can fire it only when you
choose.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
  #5   Report Post  
Old January 31st 17, 07:37 AM
Junior Member
 
First recorded activity by ExcelBanter: Jan 2017
Posts: 3
Default

Thanks for your help Garry!


  #6   Report Post  
Old January 31st 17, 09:06 AM posted to microsoft.public.excel.misc
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2015
Posts: 1,182
Default Run-time error '424': Object required

Thanks for your help Garry!

You're welcome! Was my solution useful?

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
  #7   Report Post  
Old January 28th 21, 05:27 PM
Junior Member
 
First recorded activity by ExcelBanter: Dec 2020
Posts: 25
Default How to fix run time error 424 in Excel

The “Runtime Error 424 (Object Required)” error is caused by Excel being unable to access to an “object” referenced in your VBA code:
“Objects” are anything from a variable, file, worksheet, class or module.
The error is caused by a function being called on a reference you’ve either misspelled, or have not declared.
The solution is to ensure you have all the appropriate references declared within your code. The simplest ways to fix the problem is as follows:
Locate the offending line of code (if not highlighted, use debug mode)
Identify whether you’ve referenced any objects which aren’t declared
Look for any of the functions which may be causing an error and identify they are called correctly (with the correct syntax)
Remove as much code as possible in order to get the application working again, and then add back the lines one-by-one (this isolates the error and allows yo to fix any of the issues it may have)

I hope this is helpful!
Tim Paine


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object required Run-time error '424' Ayo Excel Programming 4 August 25th 09 05:36 PM
Run-time error '424': Object Required Doug Excel Programming 2 May 27th 09 11:56 PM
Run Time error 424 Object Required Casey[_70_] Excel Programming 8 April 12th 06 07:51 PM
Object required - run time error 424. devorivivere Excel Programming 3 April 10th 04 05:43 PM
Run-time error '424': Object required Phil Bewig Excel Programming 3 February 1st 04 09:38 PM


All times are GMT +1. The time now is 01:33 AM.

Powered by vBulletin® Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright ©2004-2021 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017