VLOOKUP returns nothing / Macro gives me an error message

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
71
Hi

I presently have vlookup formulas in numerous cells that are linked to a value entered in cell F18 and a macro is linked to a value in cell H31

I need a macro that will generate a message box if the number entered in cell F18 is not found during the vlookup on Sheet2 which in turn will not populate cell H31 but if the number is found then the macro is activated

I presently have the following

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$F$18" Then
        Call Language
    End If
End Sub
and the macro triggered by the vlookup is ... the vlookup is a formula and not used in the macro

Sub Language()

VBA Code:
Sub Language()

ThisWorkbook.Worksheets("Sheet1").Unprotect ("termbuilder2020")

If Range("AE30") > 0 And (Range("E33") = "E" Or Range("E33") = "C" Or Range("E33") = Range("T31")) Then
Range("K33") = "Meets Requirements"
Range("K33").Font.Color = vbGreen
Else
Range("K33") = "Does Not Meet Requirements"
Range("K33").Font.Color = vbRed
End If

If Range("AE31") > 0 And (Range("E34") = "E" Or Range("E34") = "C" Or Range("E34") = Range("T32")) Then
Range("K34") = "Meets Requirements"
Range("K34").Font.Color = vbGreen
Else
Range("K34") = "Does Not Meet Requirements"
Range("K34").Font.Color = vbRed
End If

ThisWorkbook.Worksheets("Sheet1").Protect ("termbuilder2020")


End Sub
any help would be greatly appreciated
 
Last edited by a moderator:

Some videos you may like

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

StephenCrump

Well-known Member
Joined
Sep 18, 2013
Messages
3,790
Office Version
365
Platform
Windows
Are you looking for something along these lines:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("F18")) Is Nothing Then
        If IsError(Range("YourVLookupResult").Value) Then
            MsgBox "VLookup not found!"
        Else
            'Code to populate H31
        End If
    End If

End Sub
 

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
71
after numerous tries on my own, I finally got it to work but I will most definitely try your macro and let you know....thanks
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,179
Messages
5,509,639
Members
408,745
Latest member
YaroslavZ

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top