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

x
?
Solved

Excel formula help

Posted on 2011-09-02
12
Medium Priority
?
338 Views
Last Modified: 2012-05-12
Hi,
How do you I say while logic in excel formula.
OR maybe ue array formula to achieve it.

Please have al ook at the attached spreadsheet.

On tab key I have a key and ref.
in Ref column I am using  -> IF(ISNA(VLOOKUP(A2,rngRef,2,FALSE)),"",VLOOKUP(A2,rngRef,2,FALSE))  
To get ref_src from RANGE -> rngRef on tab KeySrc
basically just mapping the keys and getting the corresponding ref

Please let me know irf its not clear. I am sure you will figure out quikcly by looking at the attached sheet

Now What I am trying to acheive is that
there are two rows/records with same key '123'
and I am trying to get Ref  and combination of Ref_src for the same key
in the from Ref_src, Ref_src
so for key = 123
Ref would look like a,b

It would be very helpful if some one could help me out in achieving this

thanks
0
Comment
Question by:SameerMirza
[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
  • 6
  • 2
  • 2
  • +1
12 Comments
 

Author Comment

by:SameerMirza
ID: 36472798
0
 
LVL 24

Expert Comment

by:Eirman
ID: 36472803
> Please have a look at the attached spreadsheet.

There is no attachment
0
 
LVL 24

Expert Comment

by:Eirman
ID: 36472804
got it !!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:SameerMirza
ID: 36472807
sorry just uploaded
0
 

Author Comment

by:SameerMirza
ID: 36473137
any luck Eirman?
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 36473261
It's dificult to get the results in one cell with a formula (especially for more data which I asime you have) so how about the attached to get each Ref in a separate cell, i.e. in B2 paste this formula

=IF(COLUMNS($B2:B2)>COUNTIF(KeySrc!$A2:$A3,$A2),"",INDEX(KeySrc!$B2:$B3,SMALL(IF(KeySrc!$A2:$A3=$A2,ROW(KeySrc!$A2:$A3)-MIN(ROW(KeySrc!$A2:$A3))+1),COLUMNS($B2:B2))))

confirmed with CTRL+SHIFT+ENTER nad copied across - when matches are exhausted you get blanks, e.g. in your example the Ref 3 formula in D2 displays a blank, see attached

regards, barry
27288594.xls
0
 
LVL 6

Expert Comment

by:c1nmo
ID: 36473303
Could be done easily in vba, possible workaround using formulas attached.
test1.xls
0
 

Author Comment

by:SameerMirza
ID: 36473398
c1nmo

I was wondering if it would be possible for you to provide me the VBA workaround for unlimited records.
0
 

Author Comment

by:SameerMirza
ID: 36473428
Barry,

it seems to work find for the existing records.
I was wondering if it owuld be possible for you write the one that would work for
multiple records.
may be using a range for the source
0
 
LVL 6

Accepted Solution

by:
c1nmo earned 1200 total points
ID: 36473568
'\init
lKeyRow = 2
lSourceRow = 2

With Sheets("key")



'\loop through keys
Do
sKey = .Cells(lKeyRow, 1)

'\loop through source for matches

Do
sSource = Sheets("keysrc").Cells(lSourceRow, 1)
If sKey = sSource Then
sConcat = sConcat & Sheets("keysrc").Cells(lSourceRow, 2)
End If

lSourceRow = lSourceRow + 1
Loop While sSource <> ""

'\update key
.Cells(lKeyRow, 2) = sConcat

'\reset source vars
sConcat = ""
lSourceRow = 2

'\inc keyrow
lKeyRow = lKeyRow + 1

Loop While .Cells(lKeyRow, 1) <> ""


End With
0
 
LVL 50

Assisted Solution

by:barry houdini
barry houdini earned 800 total points
ID: 36473885
>I was wondering if it owuld be possible for you write the one that would work for
multiple records

Hello SameerMirza, the formula I suggested is easily extendable, e.g. changing all the A3 references to A50 we get this version

=IF(COLUMNS($B2:B2)>COUNTIF(KeySrc!$A2:$A50,$A2),"",INDEX(KeySrc!$B2:$B50,SMALL(IF(KeySrc!$A2:$A50=$A2,ROW(KeySrc!$A2:$A50)-MIN(ROW(KeySrc!$A2:$A50))+1),COLUMNS($B2:B2))))

copied across as before and down if necessary, see attached revised version

reagrds, barry
27288594v2.xls
0
 

Author Closing Comment

by:SameerMirza
ID: 36474145
Thanks alot guy.
Barry I am sure it would work for now I am happy with c1nmo's solution.
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

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