View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
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