LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default find problem

Help - I am trying to search a range row by row and find
the matching item in another range and then compare some
data in adjacent columns, and then if ok copy some other
data from one sheet to the next. I am getting an error
"object variable or With block variable not set" on the
if iserror statement - which is inteded to determine if
the item is missing from the second range.

thanks,

John

Option Explicit
Sub Compare()
'
Dim badbatch(100)
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim nomrow As Integer
Dim startkm As Integer
Dim numkm As Integer
Dim startnom As Integer
Dim colnom As Integer
Dim colkm As Integer
Dim km As Range
Dim nom As Range
Dim tender As String
'
' Define ranges
'
Range("km").CurrentRegion.Name = "km"
Range("nom").CurrentRegion.Name = "nom"
numkm = Range("km").End(xlDown).Row - Range("km").Row
startkm = Range("km").Row
colkm = Range("km").Column
startnom = Range("nom").Row
colnom = Range("nom").Column
i = 0
For j = startkm To numkm + startkm
Sheets("km").Select
tender = Sheets("km").Cells(j, colkm).Text
If IsError(Sheets("nominated").Range("nom").Find
(tender).Row) _
Then GoTo badtender
nomrow = Sheets("nominated").Range("nom"). _
Find(Sheets("km").Cells(j, colkm).Text).Row
If Sheets("km").Cells(j, colkm).Offset(0, 4).Value < _
Sheets("nominated").Cells(nomrow, colnom + 4).Value _
Then GoTo badvolume
Sheets("nominated").Cells(nomrow, colnom + 2) = _
Sheets("km").Cells(j, colkm).Offset(0, 2).Value
Sheets("nominated").Cells(nomrow, colnom + 3) = _
Sheets("km").Cells(j, colkm).Offset(0, 3).Value
GoTo nextj
badvolume:
i = i + 1
badbatch(i) = Cells(j, colkm).Text
GoTo nextj
badtender:
i = i + 1
badbatch(i) = Cells(j, colkm).Text
GoTo nextj
nextj:
Next j
If i 0 Then MsgBox ("Batch not found") Else GoTo done
Sheets("badtenders").Select
For k = 1 To i
Cells(k + 1, 1).Value = badbatch(k)
Cells(2, 5).Value = startkm
Cells(2, 6).Value = numkm
Next k
done:
End Sub

 
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
Problem with 'Find' Dave Excel Discussion (Misc queries) 5 December 15th 09 01:27 PM
Find last row macro problem Ryk Excel Discussion (Misc queries) 1 August 25th 06 02:09 PM
problem with FIND cjsmith22 Excel Worksheet Functions 3 November 17th 05 11:03 PM
find problem jon Excel Programming 2 May 24th 04 11:27 AM
Problem with FIND LSB Excel Programming 2 January 12th 04 04:16 AM


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

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"