Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel forumal to copy data from one tab to another when one column matches

Posted on 2015-02-09
6
Medium Priority
?
101 Views
Last Modified: 2015-02-09
I have an excel file with two tabs (Report & ABC)

Report is my main table and I would like to copy some fields into it from Tab ABC when there is a match on two columns...

Logic...

Formula
When value in column B (Report) is found anywhere in column A of (ABC)
Copy (ABC) Column C to (Report) Column U
0
Comment
Question by:Matt Pinkston
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Author Comment

by:Matt Pinkston
ID: 40598597
and if there is no find or the value in (ABC) column C is blank return a value of "No Rating"
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40598759
Here's a macro you can use. If you need help implementing the macro please let me know.

Sub FindAndCopy()

Dim rngFound As Range
Dim lngLastRow As Long
Dim lngRow As Long
lngLastRow = Range("B1048576").End(xlUp).Row

    Sheets("Report").Activate
    For lngRow = 1 To lngLastRow
        If Sheets("Report").Cells(lngRow, 2) <> "" Then
            With Sheets("ABC").Range("A:A")
                Set rngFound = .Cells.Find(What:=Sheets("Report").Cells(lngRow, 2), LookIn:=xlFormulas, LookAt _
                    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                    False, SearchFormat:=False)
                If Not rngFound Is Nothing Then
                    If Sheets("ABC").Cells(rngFound.Row, 3) <> "" Then
                        Sheets("Report").Cells(lngRow, 21) = Sheets("ABC").Cells(rngFound.Row, 3)
                    Else
                        Sheets("Report").Cells(lngRow, 21) = "No Rating"
                    End If
                Else
                    Sheets("Report").Cells(lngRow, 21) = "No Rating"
                End If
            End With
        End If
    Next
End Sub

Open in new window

0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 40598907
If I have understood the requirement, I think you can use a VLOOKUP formula for this, in column U of Report:

=IF(VLOOKUP(Report!B1,ABC!A:C,3,FALSE)=0,"No Rating",VLOOKUP(Report!B1,ABC!A:C,3,FALSE))

Copied down as far as required.

Thanks
Rob H
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Accepted Solution

by:
Rob Henson earned 2000 total points
ID: 40598909
Amendment to allow for No Find:

=IF(OR(ISERROR(VLOOKUP(Report!B1,ABC!A:C,3,FALSE)),VLOOKUP(Report!B1,ABC!A:C,3,FALSE)=0),"No Rating",VLOOKUP(Report!B1,ABC!A:C,3,FALSE))

Thanks
Rob H
0
 

Author Comment

by:Matt Pinkston
ID: 40598927
Rob H, like your solution but am getting a lot of

#NA and I would like this to say No Rating
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 40599257
It could be the placing of brackets, I typed the formula, on the hoof as they say, rather than copying.

I am away from desk now but will take a look when get chance
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question