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: 63
Default Error Handling with a Match Function.

Hi,

I want to do error handling when Im using Match function (last line in the
below code). Please note the code below is part of a bigger code.


What happens is that if -- ActiveCell.Value -- doesnt exist in the
ange --- ThisWorkbook.Sheets(lookingupsheetname).Range("i2: i" &
RownumberofLastBaseattribute) -- then I get an error saying
-- Run-time error 1004 unable to get the match property of the worksheet
function class. This happens EVEN AFTER I added an -- On error go to
errorreading: -- but somehow it doesnt work.
(What I wanted is that if there is an error then in the Activecell a comment
is added giving some warning.)

a) Why is my On Error not go to not working?

b) Also, how to specify in the code that Error handler is supposed to add
only a comment and after that the normal code execution should resume ?

Please guide me.

Sub MainActualUpcodes()

Dim NameOfOSWorkbook As String
Dim sh As Worksheet
Dim r As Integer
Dim opi As Integer
Dim lookingupsheetname As String
Dim RownumberofLastBaseattribute As Integer
Dim vlookuprowthroughMatch As String

NameOfOSWorkbook = "Open end data (OS).xls"
Application.ScreenUpdating = False
Workbooks(NameOfOSWorkbook).Activate

For Each sh In Workbooks(NameOfOSWorkbook).Worksheets
Worksheets(sh.Name).Activate


r = Range("A65536").End(xlUp).Row

opi = ThisWorkbook.Worksheets("Input Sheet").Range("M65536").End(xlUp).Row
lookingupsheetname = WorksheetFunction.VLookup(sh.Name,
ThisWorkbook.Worksheets("Input Sheet").Range("m7:n" & opi), 2, False)
RownumberofLastBaseattribute =
ThisWorkbook.Sheets(lookingupsheetname).Range("i65 536").End(xlUp).Row

On error go to Errorreading:
vlookuprowthroughMatch = WorksheetFunction.Match(ActiveCell.Value,
ThisWorkbook.Sheets(lookingupsheetname).Range("i2: i" &
RownumberofLastBaseattribute), 0)

' some code
'
ErrorReading:

With ActiveCell.AddComment
.Visible = True
.Text Text:="Warning:" & Chr(10) & "The mentioned attribute
doesnt exist in the Base Upcode List " _
& Chr(10) & "Update the Base list and re-run the macro"
End With

'some code
'some code

Next sh

End sub


Thanks a lot,
Hari
India


 
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 Handling #N/A with AVERAGE Function - Average of values in Row Sam via OfficeKB.com Excel Worksheet Functions 13 July 31st 05 03:59 PM
Match function, N/A error, how do I get around it? KR Excel Programming 3 January 21st 05 03:46 AM
Error Handling Open Function or query for missing Files BigNate Excel Programming 3 June 11th 04 05:22 PM
Error Handling AA2e72E[_2_] Excel Programming 0 April 27th 04 04:06 PM
Error handling in vba function Jaap Versteegh Excel Programming 4 April 20th 04 02:09 PM


All times are GMT +1. The time now is 06:47 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"