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


I am trying to search the same column in each sheet in a workbook fo
values within a range with the following, but get error 424 at line
-what have I done wrong?

Dim sh As Worksheet
Dim cell As Range
Dim LowVal As Long
Dim HiVal As Long
Dim i As Integer
Dim j As Integer
Set sh = Worksheets.Add(befo=Worksheets(1))

LowVal = 1 'these values are amended as necessary
HiVal = 10
j = 1
For i = 2 To ActiveWorkbook.Sheets.Count
For Each cell In Intersect(Sheets(i).[J:J],Sheets(i).UsedRange)
With Cell
If IsNumeric(.Value) Then
If .Value = LowVal And .Value <= HiVal Then
sh.Cells(j,"A").Value =Sheets(i).Name
sh.Cells(j,"B").Value = .Address(False,False)
j+j+1
End If
End If
End With
Next
Nex

--
Peter Rum
-----------------------------------------------------------------------
Peter Rump's Profile: http://www.excelforum.com/member.php...fo&userid=2627
View this thread: http://www.excelforum.com/showthread.php?threadid=39567

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Object required error

Try this

Dim sh As Worksheet
Dim cell As Range
Dim LowVal As Long
Dim HiVal As Long
Dim i As Integer
Dim j As Integer
Dim rng As Range
Set sh = Worksheets.Add(befo=Worksheets(1))

LowVal = 1 'these values are amended as necessary
HiVal = 10
j = 1
For i = 2 To ActiveWorkbook.Sheets.Count
Set rng = Intersect(Sheets(i).Columns("J:J"), Sheets(i).UsedRange)
If Not rng Is Nothing Then
For Each cell In rng
With cell
If IsNumeric(.Value) Then
If .Value = LowVal And .Value <= HiVal Then
sh.Cells(j, "A").Value = Sheets(i).Name
sh.Cells(j, "B").Value = .Address(False, False)
j = j + 1
End If
End If
End With
Next
End If
Next


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Peter Rump" wrote
in message ...

I am trying to search the same column in each sheet in a workbook for
values within a range with the following, but get error 424 at line 2
-what have I done wrong?

Dim sh As Worksheet
Dim cell As Range
Dim LowVal As Long
Dim HiVal As Long
Dim i As Integer
Dim j As Integer
Set sh = Worksheets.Add(befo=Worksheets(1))

LowVal = 1 'these values are amended as necessary
HiVal = 10
j = 1
For i = 2 To ActiveWorkbook.Sheets.Count
For Each cell In Intersect(Sheets(i).[J:J],Sheets(i).UsedRange)
With Cell
If IsNumeric(.Value) Then
If .Value = LowVal And .Value <= HiVal Then
sh.Cells(j,"A").Value =Sheets(i).Name
sh.Cells(j,"B").Value = .Address(False,False)
j+j+1
End If
End If
End With
Next
Next


--
Peter Rump
------------------------------------------------------------------------
Peter Rump's Profile:

http://www.excelforum.com/member.php...o&userid=26277
View this thread: http://www.excelforum.com/showthread...hreadid=395674



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Object required error


Hi Bob

Thanks for that - it gets me past the error message but selects the
empty cells rather than the ones with values in them. How do I correct
that?

As you can probably tell by now I am very much a VBA beginner!

Peter


--
Peter Rump
------------------------------------------------------------------------
Peter Rump's Profile: http://www.excelforum.com/member.php...o&userid=26277
View this thread: http://www.excelforum.com/showthread...hreadid=395674

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Object required error


Hi Bob

I think I have solved my problem. It seems to be that LowVal and HiVa
expected integers whereas I was using dates. How should I Dim thes
Values to work on dates. Temporarily I have reformatted the column s
that it works.

Pete

--
Peter Rum
-----------------------------------------------------------------------
Peter Rump's Profile: http://www.excelforum.com/member.php...fo&userid=2627
View this thread: http://www.excelforum.com/showthread.php?threadid=39567

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Object required error

Peter,

Try

Dim LowVal As Date
Dim HiVal As Date

If you had defined them As Long it would probably have worked as well.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Peter Rump" wrote
in message ...

Hi Bob

I think I have solved my problem. It seems to be that LowVal and HiVal
expected integers whereas I was using dates. How should I Dim these
Values to work on dates. Temporarily I have reformatted the column so
that it works.

Peter


--
Peter Rump
------------------------------------------------------------------------
Peter Rump's Profile:

http://www.excelforum.com/member.php...o&userid=26277
View this thread: http://www.excelforum.com/showthread...hreadid=395674





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Object required error


Bob

I have tried that and it works fine. Many thanks for your help

Pete

--
Peter Rum
-----------------------------------------------------------------------
Peter Rump's Profile: http://www.excelforum.com/member.php...fo&userid=2627
View this thread: http://www.excelforum.com/showthread.php?threadid=39567

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 DavidM[_3_] Excel Programming 1 January 13th 05 03:23 PM
Error 424 - Object Required [email protected] Excel Programming 2 December 30th 04 03:38 PM
424 Object required error J_J Excel Programming 4 November 7th 04 05:34 AM
Object Required Error Steph[_3_] Excel Programming 3 August 13th 04 03:26 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 08:14 AM.

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

About Us

"It's about Microsoft Excel"