Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DS DS is offline
external usenet poster
 
Posts: 117
Default Need help with Vlookup with and IF statements

I have two sheets in the same workbook. Master and New.

Masters data will be similar to that of New, EXCEPT, Master will have an
additional column of notes, cell H, that is not in sheet New.
I need to copy the notes column from sheet Master H to New H
But to find the proper row it has to match criteria in 3 cells.
Criteria are cells A B and C.

So I am thinking, use VLookup for A but how do I also include the AND IFs
for B and C.

There is no unique field, it has to match 3 fields.

Any help is GREATLY appreciated.

Dave

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Need help with Vlookup with and IF statements

DAve,

Enter this into New, cell H2:

=INDEX(Master!H:H,SUMPRODUCT((Master!$A$1:$A$1000= New!A2)*(Master!$B$1:$B$1000=New!B2)*(Master!$C$1: $C$1000=New!C2)*ROW(Master!$A$1:$A$1000)))

And then copy down. Adjust the 1000 to be higher than your count of rows on Master...

HTH,
Bernie
MS Excel MVP


"DS" wrote in message
...
I have two sheets in the same workbook. Master and New.

Master's data will be similar to that of New, EXCEPT, Master will have an
additional column of notes, cell H, that is not in sheet New.
I need to copy the notes column from sheet Master H to New H
But to find the proper row it has to match criteria in 3 cells.
Criteria are cells A B and C.

So I am thinking, use VLookup for A but how do I also include the AND IF's
for B and C.

There is no unique field, it has to match 3 fields.

Any help is GREATLY appreciated.

Dave



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Need help with Vlookup with and IF statements

Sub addtonew()

With Sheets("Master")
MasterLastRow = .Cells(Rows.Count, "H").End(xlUp).Row
End With
With Sheets("New")
NewLastRow = .Cells(Rows.Count, "H").End(xlUp).Row

For NewRowCount = 1 To NewLastRow
CriteriaA = .Range("A" & NewRowCount)
CriteriaB = .Range("B" & NewRowCount)
CriteriaC = .Range("C" & NewRowCount)

With Sheets("Master")
For MasterRowCount = 1 To MasterLastRow
If CriteriaA = .Range("A" & MasterRowCount) And _
CriteriaB = .Range("B" & MasterRowCount) And _
CriteriaC = .Range("C" & MasterRowCount) Then

.Range("H" & MasterRowCount).Copy _
Destination:=Sheets("New").Range("H" & NewRowCount)
End If
Next MasterRowCount
End With
Next NewRowCount
End With
End Sub

"DS" wrote:

I have two sheets in the same workbook. Master and New.

Masters data will be similar to that of New, EXCEPT, Master will have an
additional column of notes, cell H, that is not in sheet New.
I need to copy the notes column from sheet Master H to New H
But to find the proper row it has to match criteria in 3 cells.
Criteria are cells A B and C.

So I am thinking, use VLookup for A but how do I also include the AND IFs
for B and C.

There is no unique field, it has to match 3 fields.

Any help is GREATLY appreciated.

Dave

  #4   Report Post  
Posted to microsoft.public.excel.programming
DS DS is offline
external usenet poster
 
Posts: 117
Default Need help with Vlookup with and IF statements

Bernie and Joel,

You two ROCK!

1: I will certainly look at INDEX for future uses, I have never used it
before.
2: Bernie, I will use yours ASAP to get this project going.
3: Joel, I will then add yours to it as I am also automating the input of
the new data from an outside source and yours will make it a one click deal.

I appreciate all of the time everyone gives to this site!

Regards,

Dave



"Joel" wrote:

Sub addtonew()

With Sheets("Master")
MasterLastRow = .Cells(Rows.Count, "H").End(xlUp).Row
End With
With Sheets("New")
NewLastRow = .Cells(Rows.Count, "H").End(xlUp).Row

For NewRowCount = 1 To NewLastRow
CriteriaA = .Range("A" & NewRowCount)
CriteriaB = .Range("B" & NewRowCount)
CriteriaC = .Range("C" & NewRowCount)

With Sheets("Master")
For MasterRowCount = 1 To MasterLastRow
If CriteriaA = .Range("A" & MasterRowCount) And _
CriteriaB = .Range("B" & MasterRowCount) And _
CriteriaC = .Range("C" & MasterRowCount) Then

.Range("H" & MasterRowCount).Copy _
Destination:=Sheets("New").Range("H" & NewRowCount)
End If
Next MasterRowCount
End With
Next NewRowCount
End With
End Sub

"DS" wrote:

I have two sheets in the same workbook. Master and New.

Masters data will be similar to that of New, EXCEPT, Master will have an
additional column of notes, cell H, that is not in sheet New.
I need to copy the notes column from sheet Master H to New H
But to find the proper row it has to match criteria in 3 cells.
Criteria are cells A B and C.

So I am thinking, use VLookup for A but how do I also include the AND IFs
for B and C.

There is no unique field, it has to match 3 fields.

Any help is GREATLY appreciated.

Dave

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Need help with Vlookup with and IF statements

You could add an additional (hidden?) column in Master that is a
concatenation of A, B, and C. Then you could do the VLOOKUP on that
column.
=CONCATENATE(A1,"|",B1,"|",C1)

OR do it in a VBA macro.

D-C

DS wrote:
I have two sheets in the same workbook. Master and New.
Master’s data will be similar to that of New, EXCEPT, Master will have an
additional column of notes, cell H, that is not in sheet New.
I need to copy the notes column from sheet Master H to New H
But to find the proper row it has to match criteria in 3 cells.
Criteria are cells A B and C.
So I am thinking, use VLookup for A but how do I also include the AND IF’s
for B and C.
There is no unique field, it has to match 3 fields.
Any help is GREATLY appreciated.
Dave



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vlookup with AND, OR IF statements Novawitt Excel Worksheet Functions 1 November 18th 09 11:51 AM
VLOOKUP and IF Statements cranen Excel Discussion (Misc queries) 2 August 13th 09 10:26 PM
Using Vlookup with IF statements Addy Excel Programming 3 April 13th 07 04:35 PM
Using Vlookup for IF statements Addy Excel Programming 3 April 13th 07 04:17 PM
Help with Vlookup and If Statements SunnyM Excel Discussion (Misc queries) 4 February 9th 06 12:45 AM


All times are GMT +1. The time now is 12:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"