vLookup with embedded if statements?

Calboy

New Member
Joined
Feb 14, 2014
Messages
7
I'm hoping this is easier then I'm making it!

I'm trying to write some code that finds a part number in a large list by searching for key words in the descriptions for various models and then. Each of the models has a different part number which complicated this a little.

Does anybody have any ideas on what this code might look like. Can it use a VLookup with embedded If statements or something. I'm not very familiar with VBA syntax.



 
Last edited:
Now I just need to figured out how to make it search within the description instead of you having to use the actual word of the description
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Edit: Slightly misunderstood

back to drawing board
 
Last edited:
Upvote 0
Now I just need to figured out how to make it search within the description instead of you having to use the actual word of the description

Thank You! It works great! I was able to solve searching within the description by doing something like *descriptive*words*. It's not pretty, but it works great! Thanks so much for the help. I've learned a lot.
 
Upvote 0
Thank You! It works great! I was able to solve searching within the description by doing something like *descriptive*words*. It's not pretty, but it works great! Thanks so much for the help. I've learned a lot.

can you post the formula you used. i'm curious because i was stumped
 
Upvote 0
I think its done with a slight annoyance at the minute, when the seach for the description yileds nothing it makes the row reference 0 which brings back a value due to it bening part of an Array,

Ive never come across this before so will have to work something out


Excel Workbook
ABCDE
1Sequence NUMBER100015007000
2Model #PART1PART2PART3
3WIDGET 1WIDGET 2WIDGET 3
4Q'S
5Q11204993COMPCOMP
6Q21204993COMPCOMP
7W'S
8W1120499513230481323049
9W2120499513230481323049
10W3120499513230481323049
11W4120494713231291323083
12W5120494713231291323083
Sheet1
 
Upvote 0
done a workaround


on the bit that works out the row (the part of the formula below) i so 1/sum(1/row Ref)

this forces an error if the row reference is 0 and returns the same value if the row ref > 0


Code:
1/(1/SUMPRODUCT(--(('RAW DATA'!$A$1:$A$100=Sheet1!$B5)*('RAW DATA'!$B$1:$B$100=Sheet1!D$1)*(IFERROR(SEARCH(D$3,'RAW DATA'!$D$1:$D$100,1),0)>0))






Excel Workbook
ABCDE
1Sequence NUMBER100015007000
2Model #PART1PART2PART3
3WIDGET 1WIDGET 2WIDGET 3
4Q'S
5Q11204993  
6Q21204993  
7W'S
8W1120499513230481323049
9W2120499513230481323049
10W3120499513230481323049
11W4120494713231291323083
12W5120494713231291323083
Sheet1
 
Upvote 0
The equations work great, but now I'm running into a different problem. It seems like there is a glitch in excel. What I am doing is I'm running a VBA program I wrote to compare the part numbers from a previous year and highlighting parts that were used in last years models. The program works great when I hand type in the number, but when I try it on the information that output from the equation the program doesnt work. I've tried copying the data and pasting values and it still doesn't work; however, when I click on the copied cell and put the cursor at the end of the value and hit the delete key then hit enter, the program will work fine for that cell. Do you have any recommendations?

Here is the VBA code I'm running.
Sub dup() Dim cell As Range, cella As Range, rng As Range, srng As Range
Set rng2 = Sheets("MY14").Range("d3:ag110")
Set rng3 = Sheets("MY15(2)").Range("d5:ah120")
For Each cell In rng2
For Each cella In rng3
If cella > "" Then
If cella = cell Then
cella.Interior.ColorIndex = 10

End If
End If

Next cella
Next cell


End Sub
 
Upvote 0
The equations work great, but now I'm running into a different problem. It seems like there is a glitch in excel. What I am doing is I'm running a VBA program I wrote to compare the part numbers from a previous year and highlighting parts that were used in last years models. The program works great when I hand type in the number, but when I try it on the information that output from the equation the program doesnt work. I've tried copying the data and pasting values and it still doesn't work; however, when I click on the copied cell and put the cursor at the end of the value and hit the delete key then hit enter, the program will work fine for that cell. Do you have any recommendations?

Here is the VBA code I'm running.
Sub dup() Dim cell As Range, cella As Range, rng As Range, srng As Range
Set rng2 = Sheets("MY14").Range("d3:ag110")
Set rng3 = Sheets("MY15(2)").Range("d5:ah120")
For Each cell In rng2
For Each cella In rng3
If cella > "" Then
If cella = cell Then
cella.Interior.ColorIndex = 10

End If
End If

Next cella
Next cell


End Sub

VBA is not my cup of tea.
 
Upvote 0

Forum statistics

Threads
1,222,617
Messages
6,167,074
Members
452,094
Latest member
Roberto Saveru

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