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: 3
Default Error Handler only works once

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
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
Error handler linto Excel Discussion (Misc queries) 1 February 11th 10 12:17 PM
VBA Error Handler MVM Excel Programming 1 June 12th 06 07:56 PM
Form Err.Raise error not trapped by entry procedure error handler [email protected] Excel Programming 1 February 8th 06 10:19 AM
Error Handler dht[_2_] Excel Programming 5 August 19th 04 08:51 AM
error handler Fleur Excel Programming 1 November 20th 03 06:06 AM


All times are GMT +1. The time now is 02:53 PM.

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"