Private Sub Worksheet_Change(ByVal Target As Range)

Closed
sdfgh - Dec 7, 2016 at 08:25 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Dec 19, 2016 at 11:21 AM
Hello,

please do the needfull..
I am trying to run the below macro,but it is not running,can anyone help me on this please,

Private Sub Worksheet_Change(ByVal Target As Range)
Dim selectedValue As String
Dim templateValues As String
Dim fileLocation As String
Dim personName As String
Dim Subject As String


selectedValue = ActiveCell.Formula

On Error GoTo SubEnd
templateValues = Application.WorksheetFunction.VLookup(selectedValue, Sheets("Template").Range("A1:A30"), 1, False)
fileLocation = Application.WorksheetFunction.VLookup(selectedValue, Sheets("Template").Range("A1:B30"), 2, False)
Subject = Application.WorksheetFunction.VLookup(selectedValue, Sheets("Template").Range("A1:C30"), 3, False)
personName = Cells(Application.ActiveCell.Row, 6).Value & " " & Cells(Application.ActiveCell.Row, 7).Value

If selectedValue = templateValues Then
Call Client_Mails(fileLocation, Subject)
Call Oltask(selectedValue, personName)

End If
SubEnd:
End Sub

it is in worksheet-change and Application.EnableEvents-True
even though it is not running.


Thanks in advance.


Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Dec 19, 2016 at 11:21 AM
Hi sdfgh,

The formula Vlookup needs a value to look up and not a formula.

Change
selectedValue = ActiveCell.Formula
into
selectedValue = ActiveCell.value

See if that will work.

Best regards,
Trowa
0