Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I'm trying to catch an error using "on error goto line 1", whenever a tab in another file that I'm referencing does not exist. It seems to work the first time around, but not the second. I've attached the code. Any help would be greatly appreciated. Regard, Anita Sub atryThisSix() Dim i As Integer Dim j As Integer Dim k As Integer Dim myAddress, theAddress As Range, myPrice Dim myVendor As String, myProduct Dim m j = 1 k = 1 l = 2 Application.ScreenUpdating = False Windows("trial.xls").Activate Do Until Cells(k, j) = "" If Cells(k, j).Value = "f" Then myVendor = Cells(k, j).Offset(0, 6).Value myProduct = Cells(k, j).Offset(0, 7).Value Cells(k, 2).Value = myVendor Cells(k, 3).Value = myProduct Windows("Code.xls").Activate On Error GoTo line1 Workbooks("Code.xls").Sheets(myVendor).Select Columns("F:F").Select Dim cell As Range Set cell = Columns("f:f").Find(What:=myProduct, _ after:=ActiveCell, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) cell.Activate Set cell = ActiveCell ' cell.Activate myPrice = ActiveCell.Offset(0, 1).Value If Not cell Is Nothing Then Windows("trial.xls").Activate Cells(k, 12).Value = myPrice End If ' Windows("trial.xls").Activate ' Cells(k, 12).Value = myPrice Windows("trial.xls").Activate Else Cells(k, 2).Value = Cells(k, j).Offset(0, 9).Value End If line1: Windows("trial.xls").Activate k = k + 1 Loop Application.ScreenUpdating = True End Sub A *** Sent via Developersdex http://www.developersdex.com *** |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error handler | Excel Discussion (Misc queries) | |||
VBA Error Handler | Excel Programming | |||
Form Err.Raise error not trapped by entry procedure error handler | Excel Programming | |||
Error Handler | Excel Programming | |||
error handler | Excel Programming |