Excel/excel help


I have a master file containing 12000 item numbers in Column A and hyperlinked document for each item number in column B.
Now I have made a macro code (shown at the end) which is automatically display as soon as I scan the item number in Cell C1.
Now everything was working fine. But As I started creating real master file, Instead of hyperlinking by right clicking on cell, selecting hyperlink, and then choosing file location, I am hyperlinking it by using Hyperlink function as it is more convinient for me as all file locations are same and in same folder So I am just using =Hyperlink(D2&E2\) in B2 where D column contains file path and E columns contains part number.
Now hyperlink has been created as when I am clicking on it it is getting opened(So that is not a problem)
But now when I am running Macro it is showing me this error:
Run time error 9:subscript out of Range
and showing debug in  ActiveCell.Hyperlinks(1).Follow

Please Help.

Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("C1")) Is Nothing Then macro
End Sub
Sub macro()
    Dim myR As Range
    Set myR = Worksheets("Sheet1").Range("A:A").Find( _
        What:=Worksheets("Sheet1").Range("C1").Value, LookIn:=xlFormulas)
      If Not myR Is Nothing Then
        With Range("B" & ActiveCell.Row)
        End With
        MsgBox "Item Number Not Found. Please check The Number You have Entered"
        End If

End Sub

It's always difficult to debug from code alone - my GUESS is that more than or less than one cell is active - so I'd try putting msgbox activecell.address before the instruction to follow a hyperlink - this would confirm which cell is deemed to be active, which may help resolve the problem - you could also put in an "on error resume next" statement which wouldn't resolve the problem but would stop the code erroring (if this is an occassional problem).

I hope this helps but let me know if I can help further.
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Aidan Heritage


I have provided first hand support since `95 for Microsoft Office majoring in Word and Excel - support for all versions from 2 onwards. I'm based in the UK, so please allow for time differences when asking me questions from other parts of the world!


My background is in the insurance industry and call centre areas, but have been called upon to provide many varied solutions.

I'm educated to UK A level standard, but as I left school some 30 years ago that is rather irrelevent - university of life has provided more of a background!

©2016 About.com. All rights reserved.