473,508 Members | 3,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Vlookup with criteria

102 New Member
Hello Friends
I have some problems in Excel and need anybody's help. I have a file with many columns but especially I need
Drawing Number and thair Approval status.
Match Drawings Number and get its last status. Suppose

Drawing Number Rev Status
QV-00-VEN-C02-14400917-0001 0 Under Review
QV-00-VEN-C02-14400917-0001 1 Not Approve
QV-00-VEN-C02-14400917-0001 2 Approved with Comments
QV-00-VEN-C02-14400917-0001 3 Approved

I have to fill another Sheet by using Vlookup. I want to Vlookup based on Drawings and last cell of Status colums against that Drawings Number.

Excel File is attached. Thanks in advance
Attached Files
File Type: zip REPORTS1.zip (46.2 KB, 57 views)
Mar 25 '15 #1
1 2113
c1377
1 New Member
Howdy...
1) vlookup requires that you remove all empty rows from your data
2) vlookup only retrieves the 1st reponse,
...so if you want the highest revision level reported you will need to sort your data accordingly
3) even with vlookup you would be required to manually update your reference column with the exact Document name (which doesn't look like much fun)

4) a simpler solution would be to:
...copy your table to a new report tab
...sort your report
...detect & delete duplicates

5) you could even do this with a macro like so:
note: I used a button named "New_Report" to run the macro,
you will find removing this button has been commented out...


Expand|Select|Wrap|Line Numbers
  1. Sub NewReport()
  2.  
  3. ' copy sheet to new tab, colour it yellow, and name it "new Report"
  4.     Sheets("NEW EDDR").Copy Before:=Sheets(2)
  5.     Sheets("NEW EDDR (2)").Name = "New Report"
  6.         With ActiveWorkbook.Sheets("New Report").Tab
  7.             .Color = 65535
  8.             .TintAndShade = 0
  9.         End With
  10.  
  11. 'prepare sheet for sorting
  12.     Cells.Select
  13.     Cells.UnMerge
  14.     ActiveWorkbook.Worksheets("New Report").Sort.SortFields.Clear
  15.     ActiveWorkbook.Worksheets("New Report").Sort.SortFields.Add Key:=Range("B2:B9999"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
  16.     ActiveWorkbook.Worksheets("New Report").Sort.SortFields.Add Key:=Range("E2:E9999"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortTextAsNumbers
  17.  
  18. 'sort sheet by document No. and Rev
  19.         With ActiveWorkbook.Worksheets("New Report").Sort
  20.             .SetRange Range("A1:L326")
  21.             .Header = xlYes
  22.             .MatchCase = False
  23.             .Orientation = xlTopToBottom
  24.             .SortMethod = xlPinYin
  25.             .Apply
  26.         End With
  27.  
  28. 'Remove Document No. rows that have a Higher Revision Level
  29.     Columns("B:B").Select
  30.     ActiveSheet.Range("$A$1:$K$9999").RemoveDuplicates Columns:=2, Header:=xlYes
  31.  
  32. 'Sort Data by "DSCP"
  33.     Cells.Select
  34.     ActiveWorkbook.Worksheets("New Report").Sort.SortFields.Clear
  35.     ActiveWorkbook.Worksheets("New Report").Sort.SortFields.Add Key:=Range("D2:D9999"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
  36.     ActiveWorkbook.Worksheets("New Report").Sort.SortFields.Add Key:=Range("E2:E9999"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
  37.     ActiveWorkbook.Worksheets("New Report").Sort.SortFields.Add Key:=Range("B2:B9999"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
  38.         With ActiveWorkbook.Worksheets("New Report").Sort
  39.             .SetRange Range("A1:L326")
  40.             .Header = xlYes
  41.             .MatchCase = False
  42.             .Orientation = xlTopToBottom
  43.             .SortMethod = xlPinYin
  44.             .Apply
  45.         End With
  46.  
  47. 'Hide Columns & Clean Up
  48.     Columns("A:A").EntireColumn.Hidden = True
  49.     Columns("F:J").EntireColumn.Hidden = True
  50.     ActiveWindow.Zoom = 100
  51. '    ActiveSheet.Shapes.Range(Array("New_Report")).Delete
  52.     Columns("C:C").VerticalAlignment = xlTop
  53.     Range("B1").Select
  54. End Sub
Attached Files
File Type: zip Reports 2.zip (44.1 KB, 41 views)
Mar 30 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
21228
by: Fred | last post by:
I am trying to come up with a way to lookup values in Access as easily as I can in Excel. My application is looking up scores. An example lookup table below explains what I'm after: TABLE1...
2
494
by: Rebecca | last post by:
could someone tell me the correct syntax for using vlookup in visual basic
0
3995
NeoPa
by: NeoPa | last post by:
VlookUp or Vertical LookUp is a function that enables Excel to ‘Find’ related items from within a range stored elsewhere. Elsewhere can mean another excel workbook on another PC, but can also mean a...
5
17588
by: catlover30 | last post by:
HI, I need help with excel VLOOKUP! I am at a new job and really trying to solve this without asking anyone at work, since they seem th expect me to know this. What I am trying to acheive is the...
9
3613
by: Sinner | last post by:
Hi, I have a field name 'USER' in tableMAIN. How do I replace the user names with corresponding user names. I can do that in xl using vlookup but now I'm trying to find a way to do that in...
0
1064
by: loudey | last post by:
I'm using Vlookup to lookup a "Product Type" in Column "D" vs a given "Product Code" that is listed in Column A. here is the code that I'm using, 'Product Type lookup Set mg =...
0
1285
by: Balaji Gurunathan | last post by:
Hi All, I am exporting a datatable to an excel sheet in an existing workbook. In another worksheet in the same workbook, i am using vlookup function that uses data in the exported worksheet. The...
1
3876
by: garjones | last post by:
Hi everyone, first post so thanks in advance. I have been trawling sites for 2 days trying to find the answer to this so apologies if I missed something (MySQL newbie!). I have a table of...
7
1926
by: Rodney Roe | last post by:
I'm using VBA in excel 2010. I figured out that i could use vlookup to access workbooks without opening them up this is the code i've got. For i = 0 to Ubound(myData,1) -1 .Offset(i, 2) =...
5
3174
by: scrapcode | last post by:
Hi everyone. I'm trying to write a macro to copy data from one Excel sheet to another in the same workbook when a certain criteria is met. My data table is an import from an Access DB. After the...
0
7333
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.