+ Reply to Thread
Results 1 to 2 of 2

Run-time error '1004': Application-defined or object-defined error

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-20-2011
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2013
    Posts
    165

    Run-time error '1004': Application-defined or object-defined error

    Hi guys,

    I am trying to run macro through hyperlink and when trying to do that its giving me a run time error. Below is the code that i am trying to implement.

    Option Explicit
    
    Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    
    If Not Intersect(Range(Target.parent.Address), Range("$I$4:$I$5000")) Is Nothing Then
        Dim rng As Range
        ActiveCell.Offset(0, -7).Copy
        Set rng = Sheets("Sheet1").Range("A1")
        rng.Offset(0, 0).Paste
        MacroName
        Exit Sub
    End If
    
    End Sub
    its giving me an error at the following code->

        ActiveCell.Offset(0, -7).Copy
    Currently I have enabled the following references:

    Visual Basic For Application
    Microsoft Excel 12.0 Object Library
    OLE Automation
    Microsoft Office 12.0 Object Library
    Microsoft Forms 2.0 Object Library
    Windows Script Host Object Model

    thanks in advance guys...

    Cheers
    plasma33

  2. #2
    Forum Contributor
    Join Date
    06-20-2011
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2013
    Posts
    165

    Re: Run-time error '1004': Application-defined or object-defined error

    its working guys....here is the modified code->

    Option Explicit
    
    Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    
    If Not Intersect(Range(Target.parent.Address), Range("$I$4:$I$5000")) Is Nothing Then
        Sheets("Sheet2").Select
        ActiveCell.Offset(0, -7).Copy
        Sheets("Sheet1").Select
        Sheets("Sheet1").Range("A1").Select
        ActiveSheet.Paste
        MacroName
        Exit Sub
    End If
    
    End Sub
    Cheers
    plasma33

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1