Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Object Required error

I have the below code that has been working fine and still does in some
macros, however in others it has stopped and returns the 424 Object Required
error -

Dim ws As Worksheet
Dim wsName As String
Set ws = ActiveSheet
ws.Move After:=Sheets(Sheets.Count)

lastrow = Worksheets(ws.Name).Cells(Rows.Count, "A").End(xlUp).Row

Range("H2").AutoFill Range("H2:H" & lastrow)


Why would this be happening all of a sudden and only in certain macros?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Object Required error

Since you didn't indicate which line of code is giving you the error, we are
left to guess. Maybe it is this line:

lastrow = Worksheets(ws.Name).Cells(Rows.Count, "A").End(xlUp).Row

You actually don't have to use Worksheets(ws.Name) because you have already
set the object variable (ws) to the ActiveSheet. You could just use:

lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

Try this code. I took the liberty of shortening it for you. If it throws
an error, indicate to us where the error is occuring. Hope this helps! If
so, let me know, click "YES" below.

Dim LastRow As Long

With ActiveSheet
.Move After:=Sheets(Sheets.Count)

LastRow = .Cells(Rows.Count, "A").End(xlUp).Row

.Range("H2").AutoFill .Range("H2:H" & LastRow)
End With
--
Cheers,
Ryan


"Gary McCarthy" wrote:

I have the below code that has been working fine and still does in some
macros, however in others it has stopped and returns the 424 Object Required
error -

Dim ws As Worksheet
Dim wsName As String
Set ws = ActiveSheet
ws.Move After:=Sheets(Sheets.Count)

lastrow = Worksheets(ws.Name).Cells(Rows.Count, "A").End(xlUp).Row

Range("H2").AutoFill Range("H2:H" & lastrow)


Why would this be happening all of a sudden and only in certain macros?

Thanks.

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
Error 424, Object required pickytweety Excel Programming 2 April 23rd 09 06:16 PM
Object Required error Patrick Simonds Excel Programming 3 August 26th 06 07:51 PM
Object required error broogle Excel Programming 7 March 21st 05 09:01 AM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM
error 424 - Object Required blb Excel Programming 0 October 1st 03 05:32 PM


All times are GMT +1. The time now is 08:30 PM.

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

About Us

"It's about Microsoft Excel"