ISBLANK and IF inside a VLOOKUP

default_name

Board Regular
Joined
May 16, 2018
Messages
180
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
I have a table of information.
Let's call this Table 1.

Table 1[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Activity
[/TD]
[TD="align: center"]TNumber
[/TD]
[TD="align: center"]ID
[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD]Training[/TD]
[TD="align: center"][/TD]
[TD="align: center"]54465[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD]Exercise A[/TD]
[TD="align: center"]ABC111A[/TD]
[TD="align: center"]91299[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD]Exercise B[/TD]
[TD="align: center"]ABC222B[/TD]
[TD="align: center"]91300[/TD]
[/TR]
</tbody>[/TABLE]



This second table (let's call this Table 2) allows the user to select an Activity from a dropdown list (which has been created for column F).
The corresponding TNumber and ID numbers are filled in from the first table.

Table 2
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[TD="align: center"]H[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Activity
[/TD]
[TD="align: center"]TNumber
[/TD]
[TD="align: center"]ID
[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD]Exercise B[/TD]
[TD="align: center"]ABC22B[/TD]
[TD="align: center"]91300[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]


It appears to be working great in instances where an Activity has a TNumber and an ID number.
However, in Activity cases (such as Training) where there is no TNumber (only an ID number), I want the corresponding cell in the Table 2 to display a dash/hyphen (as below in cell G3).

Table 2[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[TD="align: center"]H[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Activity
[/TD]
[TD="align: center"]TNumber
[/TD]
[TD="align: center"]ID
[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD]Exercise B[/TD]
[TD="align: center"]ABC22B[/TD]
[TD="align: center"]91300[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD]Training[/TD]
[TD="align: center"]-[/TD]
[TD="align: center"]54465[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]

I figured that I could simply add an ISBLANK function with a conditional (IF) into the VLOOKUP function, but that doesn't seem to be working.
Here is how I have the TNumber cell coded (using the code inside G3 as an example).
Code:
=IF(F3="","",VLOOKUP(F3,$A$2:$C$4,IF(ISBLANK(2),"-",2)))
for the TNumber
Code:
=IF(F3="","",VLOOKUP(F3,$A$2:$C$4,IF(ISBLANK(3),"-",3)))
for the ID number

How can I make this work the way I am envisioning it?
Hope that makes sense.

Thanks in advance.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top