Hi all, Im getting a runtime error 91 when using the following code and the string Im searching on doesnt exist. Can anyone help?
FYI, the whole sub looks like this:
Code:
deleteRow = ActiveSheet.Cells.Find(What:=Find, After:=ActiveCell, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Row
FYI, the whole sub looks like this:
Code:
Sub DeleteSecretaries() MaxCounter = SecretariesLastRow ' Initialize variables. Counter = "1" Do Until Counter = MaxCounter + 1 ' Inner loop. 'Set the find value Find = Workbooks("Format BDRweekly.xls").Sheets("Secs").Range("A" & Counter).Value 'Find them Workbooks("BDRweekly.xls").Activate Sheets("Sheet2").Select ActiveSheet.Cells(1, 2).Select deleteRow = ActiveSheet.Cells.Find(What:=Find, After:=ActiveCell, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Row 'Delete the row Workbooks("BDRweekly.xls").Activate Sheets("Sheet2").Select Rows(deleteRow).Delete 'Select the same address on this sheet Workbooks("BDRweekly.xls").Activate Sheets("MI Report").Select 'And delete that row Rows(deleteRow).Delete ' Increment Counter. Counter = Counter + 1 'Reset values Find = "" ReplaceWith = "" Loop End Sub
Comment