+ Reply to Thread
Results 1 to 12 of 12

If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

Hybrid View

  1. #1
    Registered User
    Join Date
    05-20-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    6

    If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

    Hi

    I forgive my ignorance I am new to VBA and have ben trying to cut and paste various bits of code together to achieve my goal

    end goal =

    double click a cell in a column from which an embedded file (outlook message) is opened

    The column contains 100's of entries but these boil down to 5 variants (each variant has its own email)

    I can get the code to open up a single object but not to open up the object related to the value in the column

    any help would be much appreciated
    Thanks



    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    Dim Object99 As String

    Object99 = Application.WorksheetFunction.VLookup(Objective, Worksheets("email").Range("b:c"), 2, False)
    'MsgBox Object1



    If Not Intersect(Target, Range("AD:AD")) Is Nothing Then

    Application.ScreenUpdating = False

    Sheets("email").OLEObjects("Object99").Verb

    Me.Activate

    Application.ScreenUpdating = True

    Cancel = True

    End If

    End Sub

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

    Dim Object99 As String
    Not sure why you quoted Object99 in double quotes which will be considered as Text entry instead of variable value.

    Sheets("email").OLEObjects("Object99").Verb


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    05-20-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    6

    Re: If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

    Hi Apologies this was an error on my part

    I have removed the "" but it still doen snot work??

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

    Object99 = Application.WorksheetFunction.VLookup(Objective, Worksheets("email").Range("b:c"), 2, False)
    Objective refers to what?

  5. #5
    Registered User
    Join Date
    05-20-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    6

    Re: If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

    im sorry again, it was part of some code I copied and pasted...it does not mean anything

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

    Quote Originally Posted by wideboy View Post
    im sorry again, it was part of some code I copied and pasted...it does not mean anything
    Okay, try this...

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    If Not Intersect(Target, Range("AD:AD")) Is Nothing Then
        Dim Object99 As String
        
        Object99 = Application.WorksheetFunction.VLookup(Target.Value, Worksheets("email").Range("b:c"), 2, False)
        
        Application.ScreenUpdating = False
            Sheets("email").OLEObjects(Object99).Verb
            Me.Activate
        Application.ScreenUpdating = True
        
        Cancel = True
    End If
    
    End Sub

  7. #7
    Registered User
    Join Date
    05-20-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    6

    Re: If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

    Thanks mate, you are a legend...have a great weekend!

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

    You're welcome and have a nice weekend to you too...

    Also, thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] If Target.Cells(1).Address = Range("$B$5": ..(?)..)
    By Marcin4111 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2015, 06:57 AM
  2. [SOLVED] Can i use 2 different "Worksheet_Change(ByVal Target As Range)" on a sheet?
    By Viktor86HUN in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-23-2015, 08:01 AM
  3. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  4. [SOLVED] Multiple "ByVal Target As Range"
    By batchy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-08-2013, 02:50 PM
  5. Replies: 3
    Last Post: 07-30-2013, 01:38 AM
  6. Getting "..object _worksheet failed..." error with intersect for cell and named range.
    By cool1_boy1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2013, 04:17 PM
  7. Need help creating VBA looping code in "Worksheet_Change(ByVal Target As Range)"
    By jimredfield in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2012, 03:09 PM

Tags for this Thread

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