Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function BinarySearch(lookupArray As Variant, lookupValue As Variant) As Integer
- Dim intLower As Integer
- Dim intMiddle As Integer
- Dim intUpper As Integer
- intLower = LBound(lookupArray) 'type mismatch error here
- intUpper = UBound(lookupArray)
- Do While intLower < intUpper
- intMiddle = (intLower + intUpper) 2
- If lookupValue > lookupArray(intMiddle) Then
- intLower = intMiddle + 1
- Else
- intUpper = intMiddle
- End If
- Loop
- If lookupArray(intLower) = lookupValue Then
- BinarySearch = intLower
- Else
- BinarySearch = -1 'search does not find a match
- End If
- Sub Compare()
- Dim h As Integer
- For h = 1 To 1000 'iterate through rows of PLANNING BOARD
- If Sheets("PLANNING BOARD").Cells(h, 6) <> "" Then 'I want to ignore blank cells
- Dim i As Integer
- i = BinarySearch(Sheets("Copy").Range("A:A"), Sheets("PLANNING BOARD").Cells(h, 6))
- If i <> -1 Then
- 'delete row and shift up
- Sheets("Copy").Rows(i).EntireRow.Delete Shift:=xlUp
- End If
- End If
- Next h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement