0

Hi I have a quick question, and the solutions found here didnt work and were 6 years old.

ik have a little vba code that links to another page of the workbook where it gets the page name from another cell.

Sub link()

    Sheets(Range("L7").Value).Activate
    Range("J3").Select

End Sub

It works like a charm, only if the page it wants to link to does not exist i get an error 9 because it wants to link to something that isn't there. Is there any way to remove the error and if it triggers just doesnt do anything?

perbrethil
  • 131
  • 1
  • 12
  • 2
    `On Error` look at error handling in VBA. – Nathan_Sav Dec 09 '20 at 12:40
  • 2
    If you are dealing with multiple sheets, you should probably avoid things like `Range("L7").Value` and instead use things like `Sheets(1).Range("L7").Value`. Also, it seems that you might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/q/10714251/4996248). – John Coleman Dec 09 '20 at 12:58

0 Answers0