![]() |
Error handling
I am unable to handle a ceratin error that crops up when
the following code is run. Sub compare() Application.ScreenUpdating = False Dim cell As Range For Each cell in Sheets("Sheet2").Range("A2:A501") Range("E6:E" & Range("E65536").End(xlUp).Row).Find (cell.Value).Activate 'do stuff if cell.value found Next cell Application.ScreenUpdating = True End Sub My problem occurs when a value on sheet2 is not found in column E on sheet1. I need an error handler to skip the part that does stuff and starts again at Next cell. Thanks in advance. Gareth |
Error handling
Sub compare()
dim result as range Application.ScreenUpdating = False Dim cell As Range For Each cell in Sheets("Sheet2").Range("A2:A501") set result = Range("E6:E" & Range("E65536").End(xlUp).Row).Find( (cell.Value)) IF not result is nothing then 'do stuff if cell.value found End If Next cell Application.ScreenUpdating = True End Sub -- Patrick Molloy Microsoft Excel MVP --------------------------------- I Feel Great! --------------------------------- "Gareth" wrote in message ... I am unable to handle a ceratin error that crops up when the following code is run. Sub compare() Application.ScreenUpdating = False Dim cell As Range For Each cell in Sheets("Sheet2").Range("A2:A501") Range("E6:E" & Range("E65536").End(xlUp).Row).Find (cell.Value).Activate 'do stuff if cell.value found Next cell Application.ScreenUpdating = True End Sub My problem occurs when a value on sheet2 is not found in column E on sheet1. I need an error handler to skip the part that does stuff and starts again at Next cell. Thanks in advance. Gareth |
All times are GMT +1. The time now is 01:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com