Solved

Excel formula help

Posted on 2011-09-02
12
332 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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 300 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 200 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
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…

631 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