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

x
?
Solved

Excel Conditional Column Input

Posted on 2011-03-15
5
Medium Priority
?
328 Views
Last Modified: 2012-05-11
From the sample spreadsheet attached, I'd like some help with a macro or statement which as soon as a tag number is entered on the right side of the fill bar in the TAG NO field, it looks for and matches the same tag number on the left side of the sheet, and then populates the rest of the columns to match the tag number.  If there's no match, I'd like the tag number column on the right to return "no match."  
Palletized-Product-Status.xls
0
Comment
Question by:mrherndon
[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
  • 2
  • 2
5 Comments
 
LVL 50

Accepted Solution

by:
barry houdini earned 2000 total points
ID: 35142007
Try this formula in Q2 copied down the column

=IF(P2="","",IF(COUNTIF($A$2:$A$5000,$P2),IF(INDEX(B$2:B$5000,MATCH($P2&"",$A$2:$A$5000,0))="","",INDEX(B$2:B$5000,MATCH($P2&"",$A$2:$A$5000,0))),"No Match"))

and in R2 copied across to AC2 and down all those columns

=IF($P2="","",IF($Q2="No Match","",IF(COUNTIF($A$2:$A$5000,$P2),IF(INDEX(C$2:C$5000,MATCH($P2&"",$A$2:$A$5000,0))="","",INDEX(C$2:C$5000,MATCH($P2&"",$A$2:$A$5000,0))),"No Match")))

see attached

regards, barry
26888994.xls
0
 
LVL 42

Expert Comment

by:dlmille
ID: 35142010
You just need a simple conditional vlookup statement, like

[Q2] =IF(ISNA(VLOOKUP($P2,$A:$N,COLUMN(B$2),0)),"No Match",VLOOKUP($P2,$A:$N,COLUMN(B$2),0))

and this can be copied across the columns to the right, and/or down.  As you have formatted, it depends on the order of the columns on the left.  As your columns on the left are the same, this VLOOKUP is a simple approach.

You only need a macro if you want the Tag No column to show "No Match" and that would be tough on the user, overwritting the number input with "No Match".  As an alternative, this formula fills all the columns to the right of Tag No with "No Match".

PS - you might also consider adding a Data Validation Field on the Tag No entry field, that way, only valid data can be pulled up on the right - never a "No Match" case!

See attached.

Enjoy!

Dave
Palletized-Product-Status-r1.xls
0
 
LVL 20

Expert Comment

by:Ardhendu Sarangi
ID: 35142012
If you have empty cells within the same row and you don't want to add the ";" to the cells then you can also try this -
this code will skip empty cells.
Sub addme()
    For i = 1 To Cells(65536, "A").End(xlUp).Row
        If Right(Range("A" & i), 1) <> ";" And Range("A" & i) <> "" Then
            Range("A" & i) = Range("A" & i) & ";"
        End If
    Next
End Sub

Open in new window

0
 
LVL 20

Expert Comment

by:Ardhendu Sarangi
ID: 35142016
sorry wrong post... pls ignore.
0
 
LVL 42

Expert Comment

by:dlmille
ID: 35176986
@ mrherndon - I'm curious if you tried my solution.

Cheers,

Dave
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

688 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