Dear all,
I have DATA 1 and DATA 2
And, I have to iterate every DATA 1 to every DATA 2
For example:
DATA 1 | DATA 2
J | J
F | J
S | F
RESULT
J | J
J | J
J | F
F | J
F | J
F | F
S | J
S | J
S | F
I attached the file for clear example
Could it be automatically by macros?
Any help would be appreciated
Thanks,
Mut
Courtesy of martindwilson...I saw him do this today...
In I1 =INDEX($A$2:$A$12,MATCH(J2&K2,INDEX($B$2:$B$12&$C$2:$C$12,0),0))
In L1 =INDEX($E$2:$E$12,MATCH(M2&N2,INDEX($F$2:$F$12&$G$2:$G$12,0),0))
But the formula need values in coloumn J&K or M&N. How MATCH will work if we don't know those values of iteration before.
What I need is the iteration from range A2:C12 with E2:G7..
Thanks,
MT
The VBA approach to this problem:
(sheet attached)Code:Option Explicit Sub IterateDataSets() 'Jerry Beaucaire 5/2/2010 'Duplicate a 2nd range of data once for each 'row of data in 1st range of data Dim LR As Long, Rw As Long, NR As Long Dim CpyRNG As Range Application.ScreenUpdating = False Range("I:N").Clear LR = Range("A" & Rows.Count).End(xlUp).Row Set CpyRNG = Range("E2", Range("E2").End(xlDown).End(xlToRight)) For Rw = 2 To LR NR = Range("L" & Rows.Count).End(xlUp).Row + 1 CpyRNG.Copy Range("L" & NR) Range("A" & Rw).Resize(, 3).Copy Range("I" & NR).Resize(CpyRNG.Rows.Count) Next Rw Set CpyRNG = Nothing Range("I1") = "RESULT" Range("I1").Font.Bold = True Application.ScreenUpdating = True End Sub
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Jeffrey, please continue the thread discussion in the open forum, as per the Forum Rules. (See rule #4) Thanks.Originally Posted by jeffreybrown (via Private Message)
To simply see the address is easy:
...will print the range in the Immediate Window (CTRL-G to see it if it's not open already).Code:Debug.Print CpyRNG.Address
You need to see individual values within the CpyRNG? Any particular reason why? That starts to get a bit ugly to read code-wise, and I don't do that very often. If the values inside the CpyRNG are relevant to the copy procedure in some way, I would probably rethink the whole thing, so more info makes it easier to understand what you're thinking.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
No I don't need to see anything in particular outside of the address for Set CpyRNG.
I keep forgetting about Debug.Print and that answers the question.
Thanks for helping again...
Edited down.
Last edited by JBeaucaire; 05-03-2010 at 09:11 PM.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Woww.. it works!!
Thanks for your help...
Regards,
Mut
If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks